Run ID:48379
提交时间: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; }