Max6700 @ 2023-05-23 22:09:20
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int n;
int main(){
cin>>n;
a[0]=a[1]=1;
for(int i=2;i<=n;i++)
a[i]=a[i-1]+a[i-2];
cout<<a[n];
return 0;
}
(简洁明了的50分代码
by Max6700 @ 2023-05-23 22:34:20
注:本人还在等待救世主题目解脱猿的降临ing……
by GWBailang @ 2023-05-23 22:47:21
@Max6700 你就不要用这种数组记录了,用string数组记录,然后写一个高进度加法的函数就行了吗
by Max6700 @ 2023-05-24 12:15:18
@GWBailang 不会……(在机房的屑)
by GWBailang @ 2023-05-24 16:48:03
@Max6700 呃……
by Max6700 @ 2023-05-24 18:42:24
@GWBailang ha
by Max6700 @ 2023-05-24 18:54:16
@GWBailang 又又又又又又又又又又又又又又又看了看题解,决定用int数组做
by Max6700 @ 2023-05-24 19:23:42
@GWBailang
自己又写了一道(照着题解)但还是错……求助+1;
#include<bits/stdc++.h>
using namespace std;
int a[5010][5010];
int n;
int len=1;
void jia(int m)
{
for(int i=1;i<=len;i++)
a[m][i]=a[m-1][i]+a[m-2][i];
for(int i=1;i<=len;i++)
if(a[m][i]>=10)
{
a[m][i+1]+=a[m][i]/10;
a[m][i]=a[m][i]%10;
if(a[m][len+1])
len++;
}
}
int main(){
cin>>n;
a[1][1]=a[2][1]=1;
for(int i=3;i<=n;i++)
jia(i);
for(int i=len;i>=1;i--)
cout<<a[n][i];
return 0;
}
by GWBailang @ 2023-05-24 19:30:47
@Max6700
https://www.luogu.com.cn/blog/559442/suan-fa-gao-jing-du-yi
by Max6700 @ 2023-05-24 19:31:29
@GWBailang !thx++;
by Max6700 @ 2023-05-24 19:37:00
@GWBailang 过了!!!!
https://www.luogu.com.cn/record/111152777
主函数的a赋值赋错了……