ECNUAT_LZX @ 2022-11-15 00:30:46
第一次遇到高精超时,qwq
#include<bits/stdc++.h>
using namespace std;
int fib[5005][5005],len=1;
int main(){
int n;
scanf("%d",&n);
fib[1][1]=1,fib[2][1]=2;
for(int i=3;i<=n;i++){
int jw=0;
for(int j=1;j<=len;j++){
fib[i][j]=fib[i-1][j]+fib[i-2][j]+jw;
if(fib[i][j]>=10)len++;
jw=fib[i][j]/10;
fib[i][j]%=10;
}
if(jw)fib[i][len]=jw;
}
len=5000;
while(fib[n][len]==0)len--;
for(int i=len;i>=1;i--)printf("%d",fib[n][i]);
return 0;
}
by _luanyi_ @ 2022-11-15 06:58:48
if(fib[i][j]>=10)len++;
这句话应该有问题
by _luanyi_ @ 2022-11-15 07:00:16
#include<bits/stdc++.h>
using namespace std;
int fib[5005][5005],len=1;
int main(){
int n;
scanf("%d",&n);
fib[1][1]=1,fib[2][1]=2;
for(int i=3;i<=n;i++){
int jw=0;
for(int j=1;j<=len;j++){
fib[i][j]=fib[i-1][j]+fib[i-2][j]+jw;
jw=fib[i][j]/10;
fib[i][j]%=10;
}
if(jw)fib[i][++len]=jw;
}
len=5000;
while(fib[n][len]==0)len--;
for(int i=len;i>=1;i--)printf("%d",fib[n][i]);
return 0;
}
by ECNUAT_LZX @ 2022-11-15 17:31:50
@luanyi 栓 q !