Gcx_20121118 @ 2023-08-12 20:26:41
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int f[5005][1005], n;
void StoBIG(string s, int a[])
{
int len = s.size();
for (int i = 1; i <= len; i++) a[i] = s[len - i] - '0';
a[0] = len;
}
void printBIG(int a[])
{
for (int i = a[0]; i >= 1; i--) cout << a[i];
cout << endl;
}
void addBIG(int a[], int b[], int c[])
{
int lenc = max(a[0], b[0]), u = 0;
for (int i = 1; i <= lenc; i++)
{
int t = u;
if (i <= a[0]) t += a[i];
if (i <= b[0]) t += b[i];
u = t / 10;
c[i] = t % 10;
}
if (u > 0) c[++lenc] = u;
c[0] = lenc;
}
int main()
{
cin >> n;
StoBIG("1", f[1]);
StoBIG("2", f[2]);
for (int i = 3; i <= n; i++) addBIG(f[i - 1], f[i - 2], f[i]);
printBIG(f[n]);
return 0;
}
by 黄海辰 @ 2023-08-12 20:31:27
@Gcx_20121118
f[5005][3005]
by Gcx_20121118 @ 2023-08-12 20:36:04
谢谢大佬!