Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
57857 | 孙诗皓 | 火车上的人数 | C++ | Accepted | 3 MS | 272 KB | 506 | 2023-09-10 19:51:30 |
#include<iostream> using namespace std; int main() { int a,n,m,b,d[16]={0},x[16]={0},s[16]={0}; cin>>a>>n>>m>>b; d[1]=d[2]=a; s[1]=a; for (int i=0;i<m;i++){ x[2]=s[2]=i; for (int j=3;j<=n-1;j++){ s[j]=s[j-1]+s[j-2]; x[j]=s[j-1]; d[j]=d[j-1]+s[j]-x[j]; } if (d[n-1]==m) { cout<<d[b]; return 0; } } cout<<"No answer."; return 0; }