10分求助!!!
查看原帖
10分求助!!!
1276195
stepz00zy楼主2024/7/25 19:11
#include <bits/stdc++.h>
using namespace std;
int a,b,m,n,day;
int tp,tp1,tp2,ans;
int main()
{
	cin>>a>>b>>m>>n;
	tp1=a;
	tp2=b;
	ans=a+b;

	for(int i=1;i<=n;i++)
	{
		tp=tp1+tp2;
		if(tp<=m){
		ans+=tp;
		tp1=tp2;
		tp2=tp;
		}    
	}   
	cout<<ans;
 	return 0;
}

思路就是不停替换

蒟蒻求大佬帮忙!!

2024/7/25 19:11
加载中...