80分玄关
查看原帖
80分玄关
1045513
Tiancheng123楼主2024/7/29 14:24
#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;
 } 
2024/7/29 14:24
加载中...