Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
48379 | 舒晨扬 | 火车上的人数 | C++ | Accepted | 3 MS | 268 KB | 706 | 2023-05-27 14:45:47 |
//#include<bits/stdc++.h> #include<iostream> using namespace std; int t[16] = {}; int up[16] = {}; int down[16] = {}; int main(){ //freopen("a.in";,"r",stdin); //freopen("b.out","r",stdout); int a,n,m,x;//共有n个车站,始发站上车的人数为a,最后一站下车的人数是m(全部下车) cin >> a >> n >> m >> x; up[1] = a; t[1] = a; down[1] = 0; for(int i = 0;i<= m;i++){ t[2] = a; up[2] = i; down[2] = i; for(int j = 3;j <= n;j++){ up[j] = up[j - 1] + up[j - 2]; down[j] = up[j - 1]; t[j] = t[j - 1] + up[j] - down[j]; } if(t[n - 1] == m){ cout << t[x] << endl; return 0; } } cout << "No answer." << endl; return 0; }