Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
117613 夏梓瑞 火车上的人数 C++ Accepted 1 MS 284 KB 744 2025-04-19 15:10:23

Tests(5/5):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min()\fabs() #include<ctime> #include<cstdlib> #include<cstring> using namespace std; int main(){ long long a,n,m,x,b[10000],shang[10000],xia[10000]; cin>>a>>n>>m>>x; b[1]=b[2]=a; shang[1]=a; for(int i=0;i<=m;i++){ xia[2]=i; shang[2]=i; for(int j=3;j<n;j++){ shang[j]=shang[j-1]+shang[j-2]; xia[j]=shang[j-1]; b[j]=b[j-1]+shang[j]-xia[j]; } if(b[n-1]==m){ cout<<b[x];return 0; } } cout<<"No answer."; return 0; }