50分 !! 求助!! 在线等!!!
查看原帖
50分 !! 求助!! 在线等!!!
742221
Happy_Doggie楼主2023/5/28 10:58
#include<bits/stdc++.h>
#define MX 5000 + 10
using namespace std;
int flage[MX];
typedef long long LL;
int f(int x) {
	if (flage[x] != 0) {
		return flage[x];
	}
	if (x == 1 || x == 2) {
		return x;
	}
	flage[x] = f(x - 1) + f(x - 2);
	return flage[x];
}
int main(){

	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
	cin >> n;
	cout << f(n);
	return 0;
}

2023/5/28 10:58
加载中...