50分求助

P1011 [NOIP1998 提高组] 车站

@[SD20130714](/user/752477) 你的 $on$ 和 $off$ 没有更新啊,都是 $a$,所以会wa
by yutong_Seafloor @ 2023-07-11 20:06:21


@[SD20130714](/user/752477) 而且第二站上的人不一定是 $a$,题目还有一个 $m$ 还没用,给你了是要用的,可以去推理一下第二站上下车的人\ (让蒟蒻思考一下怎么写……)
by yutong_Seafloor @ 2023-07-11 20:16:06


@[yutong_Seafloor](/user/773747) 谢谢,已关。
by Hallow_Deathly @ 2023-07-11 20:43:29


@[SD20130714](/user/752477) 可以这样写,全ac ``` #include<iostream> using namespace std; int ta[21],tb[21]; int main() { int a,n,m,x; cin>>a>>n>>m>>x; ta[1]=1;ta[2]=1;ta[3]=2; for(int i=4;i<n;i++) { ta[i]=ta[i-1]+ta[i-2]-1; tb[i]=tb[i-1]+tb[i-2]+1; } int b=(m-a*ta[n-1])/tb[n-1]; cout<<ta[x]*a+tb[x]*b<<endl; return 0; } ```
by all___right @ 2023-07-22 21:07:14


**$\text{\color{8E44AD}此贴结}$**
by Hallow_Deathly @ 2023-10-13 20:16:14


|