30分求调
查看原帖
30分求调
1378709
Yue_Hao楼主2025/2/7 20:23
//#include <bits/stdc++.h>
#include <stdio.h>
#define int long long
//using namespace std;
/*
inline unsigned long long read(){
	unsigned long long x = 0, f = 1;
	char ch;
	ch = _getchar_nolock();
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = _getchar_nolock();
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = _getchar_nolock();
	}
	return (x * f);
}
*/
int score[1005];
signed main(){
	int a, b, n, m, ans = 0;
	scanf("%lld%lld%lld%lld", &a, &b, &m, &n);
	score[1] = a;
	score[2] = b;
	ans += a;
	ans += b;
	for(int i = 3; i <= n; i++){
		score[i] = score[i - 1] + score[i - 2];
		if(score[i] > m) break;
		ans += score[i];
	}
	printf("%lld", ans);
	return 0;
}
2025/2/7 20:23
加载中...