Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
40653 | 张添杰 | 火车上的人数 | C++ | Accepted | 1 MS | 272 KB | 401 | 2022-10-17 18:37:55 |
#include<bits/stdc++.h> 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; }