Tiancheng123 @ 2024-07-29 14:24:15
#include <bits/stdc++.h>
using namespace std;
int n;
struct node
{
int a[310];
int len = 0;
void out()
{
for(int t = len;t >= 0;t--)
{
printf("%d",a[t]);
}
}
};
node operator + (node a,node b)
{
node cnt = a;
cnt.len = max(a.len,b.len);
int maxn = cnt.len;
for(int i = 0;i <= b.len;i++)
{
cnt.a[i] += b.a[i];
maxn = max(maxn,i);
if(cnt.a[i] >= 10)
{
cnt.a[i + 1]++;
cnt.a[i] %= 10;
maxn = max(maxn,i + 1);
}
}
cnt.len = maxn;
return cnt;
}
node ans[5010];
int main()
{
scanf("%d",&n);
ans[0].a[0] = 1;
ans[1].a[0] = 1;
for(int t = 2;t <= n;t++)
{
ans[t] = ans[t - 1] + ans[t - 2];
}
ans[n].out();
return 0;
}
by ___Furina___ @ 2024-07-29 14:34:53
@Tiancheng123 把
by Tiancheng123 @ 2024-07-29 14:35:23
@Furina 这么大??6
by Tiancheng123 @ 2024-07-29 14:36:23
@Furina 过了,已关注
by ___Furina___ @ 2024-07-29 14:37:21
@Tiancheng123 你可以尝试计算空间
一个
那么空间为
by Tiancheng123 @ 2024-07-29 14:41:51
@Furina 感谢dalao手把手教学