.

P1255 数楼梯

Tan_Transparent @ 2022-07-07 22:26:13

#include<bits/stdc++.h>
using namespace std;
#define maxn 1000
struct BigInt{
    int len,a[maxn];
    BigInt(int x=0){
        memset(a,0,sizeof(a));
        for(len=1;x;a[len]=x%10,x/=10,len++);
        len--;
    }
    int &operator[](int i){return a[i];}
    void flatten(int L){
        len=L;
        for(int i=1;i<=len;a[i+1]+=a[i]/10,a[i]%=10,i++);
        for(;!a[len];len--);
    }
    void print(){for(int i=max(len,1);i>=1;printf("%d",a[i]),i++);}
};
BigInt operator+(BigInt a,BigInt b){
    BigInt c;
    int len=max(a.len,b.len);
    for(int i=1;i<=len;c[i]=a[i]+b[i],i++)
    c.flatten(len+1);
    return c;
}
int main(){
    BigInt s1(1),s2(2),s3(0);
    int n;
    cin>>n;
    for(int i=1;i<=n-2;i++){
        s3=s1+s2;
        s1=s2;
        s2=s3;
    }
    s3.print();
}

全RE


by 3a51_ @ 2022-07-07 22:32:50


by TernaryTree @ 2022-07-07 22:35:10

屑标题


by xinggancaixukun @ 2022-07-07 22:53:51

解锁新词汇:fxbtd = 反向标题党


by ImposterAnYu @ 2022-07-07 23:03:54


by Nick801102 @ 2022-07-10 16:07:01

https://xn--wcs.tk/g1!25


by Tan_Transparent @ 2022-07-21 08:00:46

@owo_ImposterAnYu_owo 前来考古还不知道发生了什么


by ImposterAnYu @ 2022-07-21 11:02:18

@Tan_Transparent 所以您这帖子啥意思……


by Tan_Transparent @ 2022-07-21 14:13:39

@owo_ImposterAnYu_owo 不知道我的大整数结构体咋错了。。。。。。。。。


|