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 05:22:19
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 ABCDEFG
1jzlb_trz诗剑行7541:12:2421:08:4229:42:4330:18:19(-2)170:36:04(-4)30:53:28127:52:03(-1)128:21:05
2jzlb_cxr_dsx小*最*71715:00:27245:09:28315:29:14(-2)245:26:11170:35:20245:30:48245:52:10246:17:16
3jzlb_gcx顾辰曦6559:29:1857:05:4081:30:13(-8)81:45:10(-1)170:37:56(-3)81:14:32(-4)81:15:47(-2)(-9)
4jzlb_chengyixuan程意轩6805:05:5508:08:21147:25:51(-20)169:13:28(-14)170:36:00(-16)145:17:23(-2)145:44:52(-4)
5jzlb_xyx谢宇轩4483:13:2279:42:40(-8)170:35:36(-18)79:37:07(-1)147:17:59
6jzlb_lxb罗刹怒海3282:16:1130:52:06(-1)(-2)79:28:58(-1)170:35:07(-2)
7jzlb_txyCoco is coo!3412:16:0682:45:45(-1)(-2)153:54:45(-3)170:35:36(-11)(-2)
8jzlb_gzj耿老师3569:45:32245:05:23153:36:46(-1)170:23:23(-1)