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 20:28:25
Finished

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


Problem ID    User    Language    Result   

RunID User Nick Name Problem ID Result Memory Time Language Code Length Submit Time
75740jzlb_trz诗剑行
A
Accepted
2020 KiB
0 ms
C++312 bytes2023-03-20 09:08:42
75723jzlb_chengyixuan程意轩
B
Runtime Error
2760 KiB
0 ms
C++281 bytes2023-03-19 21:17:43
75721jzlb_chengyixuan程意轩
B
Runtime Error
2764 KiB
0 ms
C++278 bytes2023-03-19 21:15:19
75720jzlb_chengyixuan程意轩
B
Runtime Error
2764 KiB
0 ms
C++276 bytes2023-03-19 21:14:24
75716jzlb_chengyixuan程意轩
B
Runtime Error
2764 KiB
0 ms
C++289 bytes2023-03-19 21:10:46
75715jzlb_chengyixuan程意轩
B
Runtime Error
2332 KiB
0 ms
C++283 bytes2023-03-19 21:09:18
75714jzlb_chengyixuan程意轩
B
Runtime Error
2024 KiB
0 ms
C++276 bytes2023-03-19 21:07:36
75712jzlb_chengyixuan程意轩
B
Runtime Error
2024 KiB
0 ms
C++276 bytes2023-03-19 21:06:00
75711jzlb_chengyixuan程意轩
B
Runtime Error
2024 KiB
0 ms
C++276 bytes2023-03-19 21:05:18
75704jzlb_chengyixuan程意轩
A
Accepted
2020 KiB
0 ms
C++191 bytes2023-03-19 20:08:21