CONTEST ID : 1546 - 3.19递推练习

#include<bits/stdc++.h>
using namespace std;
int a[20005],b[20005],c[20005];
int main(){
//a[i]=a[i-1]+a[i-2];
int n;
cin>>n;
a[0]=1;//加数1 
b[0]=2;//加数2
int A=1;//数位长度
int jw=0;//进位
for(int i=3;i<=n;i++){//从第3个开始算 
jw=0;
for(int j=0;j<A;j++){//做加法 
c[j]=a[j]+b[j]+jw;
jw=c[j]/10;//大于等于10有进位 
c[j]=c[j]%10;//保留个位 
}
if(jw==1){//数位变多了 
c[A]=1;
A++;//记录数位增加了 
}
for(int k=0;k<A;k++){
a[k]=b[k];
b[k]=c[k];

}
if(n==1)
cout<<1;
else if(n==2)
cout<<2;
else {
for(int i=A-1;i>=0;i--)
cout<<c[i];
}
return 0; 
}


SERVER TIME : 2024-11-24 03:12:49
Finished

STATUS : End    OPEN : Public
Start Time : 2023-03-19 12:00:00
End Time : 2023-04-02 16:00:00


Download

Standing User Nick Name Solved TIME PENALTY Mark ABCDEFG
1jzlb_trz诗剑行7541:12:2470021:08:4229:42:4330:18:19170:36:0430:53:28127:52:03128:21:05
2jzlb_cxr_dsx小*最*71715:00:27700245:09:28315:29:14245:26:11170:35:20245:30:48245:52:10246:17:16
3jzlb_gcx顾辰曦6559:29:1861357:05:4081:30:1381:45:10170:37:5681:14:3281:15:47(+13)
4jzlb_chengyixuan程意轩6805:05:5560008:08:21147:25:51169:13:28170:36:00145:17:23145:44:52
5jzlb_xyx谢宇轩4483:13:2242079:42:40(+20)170:35:3679:37:07(+0)147:17:59
6jzlb_lxb罗刹怒海3282:16:1134030:52:06(+40)79:28:58170:35:07
7jzlb_txyCoco is coo!3412:56:0631082:45:45(+0)153:54:45170:35:36(+10)
8jzlb_gzj耿老师3569:45:32300245:05:23153:36:46170:23:23