Happy_Doggie @ 2023-05-28 10:58:19
#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;
}
by ninji @ 2023-05-28 11:02:43
@weee 要高精度
by Happy_Doggie @ 2023-05-28 11:05:07
高精必须要字符串啊
by Happy_Doggie @ 2023-05-28 11:05:40
这是整型数组啊
by KAqwq @ 2023-05-28 11:10:06
?这题并不一定需要字符串啊
另外,建议递推做,不要递归
by Happy_Doggie @ 2023-05-28 11:11:28
哦好
by ninji @ 2023-05-28 11:23:32
@KAqwq 对呀