Run ID:123283
提交时间:2025-06-28 17:35:16
#include<bits/stdc++.h> using namespace std; int main() { int a,n,m,x; cin>>a>>n>>m>>x; int up[16]= {0}; int down[16]= {0}; int people[16]= {0}; up[1]=a; down[1]=0; people[1]=a; for (int b=0; b<=m; b++) { up[2]=b; down[2]=b; people[2]=a; for (int i=3; i<n;i++) { up[i]=up[i-1]+up[i-2]; down[i]=up[i-1]; people[i]=people[i-1]+up[i]-down[i]; } if (people[n-1]==m) { cout<<people[x]<<endl; return 0; } } cout<<"No answer."; return 0; }