P1011 车站
https://www.luogu.org/problem/P1011
车上人数 上车人数
a a
a y
2a a+y
2a+y a+2y
3a+2y 2a+3y
4*** 3a+5y
6a+7y 5a+8y
9a+12y 8a+13y
14a+20y 13a+21y
22a+33y 21a+34y
4***=32 y=3
code:
#include<cstdio>
using namespace std;
double now[10005];
double shang[10005];
int main()
{
double a,m;
int n,x;
scanf("%lf%d%lf%d",&a,&n,&m,&x);
now[1]=1;
now[2]=1;
now[3]=2;
for(int i=4;i<n;i++)
{
now[i]=now[i-1]+now[i-2]-1;
shang[i]=shang[i-1]+shang[i-2]+1;//结果发现车上人数是前两次的和-1;上车人数是前两次的和+1;
}
double y=(m-now[n-1]*a)/shang[n-1];
printf("%d\n",(int)(now[x]*a+shang[x]*y));
return 0;
}