seven7777 @ 2021-03-01 19:25:18
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
int num[5010]={0};
cin>>n;
num[1]=1,num[2]=2;
for(int i=3;i<=n;i++)
{
num[i]=num[i-1]+num[i-2];
}
cout<<num[n]<<endl;
return 0;
}
by feicheng @ 2021-03-01 19:30:53
高精度
by 万万没想到 @ 2021-03-01 19:32:40
@seven7777 高精,输出答案会爆longlong
by seven7777 @ 2021-03-01 19:58:06
@万万没想到 那怎么改呢
by _Emiria_ @ 2021-03-01 20:15:52
@seven7777 改这句
num[i]=num[i-1]+num[i-2];
具体参考高精加模板