Ar_cher @ 2023-04-09 10:42:31
90pts:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1001;
int m,n;
int a[N]={0},b[N]={0},c[N]={0},x=1000;
void f(int a[],int b[]){
for(int i=1;i<=1000;i++) a[i]+=b[i];
for(int i=1;i<=1000;i++){
if(a[i]>=10){
a[i+1]+=a[i]/10;
a[i]%=10;
}
}
}
void swapx(int a[],int b[]){
for(int i=1;i<=1000;i++) a[i]=b[i];
}
signed main(){
cin>>n;
a[1]=1;
b[1]=2;
if(n<=3){
cout<<n;
exit(0);
}
for(int i=3;i<=n/*-m-2*/;i++){
f(a,b);
swapx(c,a);
swapx(a,b);
swapx(b,c);
}
for(int i=1000;i>=1;i--){
if(c[i]==0) x--;
else break;
}
for(int i=x;i>=1;i--) cout<<c[i];
return 0;
}
by Lovely_Doggie @ 2023-04-09 10:58:02
请注意数据范围和循环次数
by Lovely_Doggie @ 2023-04-09 10:58:19
@YoudaFarmer
by Ar_cher @ 2023-04-09 11:19:18
@Lovley_Doggie 6
by Lovely_Doggie @ 2023-04-09 11:19:41
@YoudaFarmer 9