80分求助

P1255 数楼梯

A_chicken_boy @ 2022-10-15 21:45:13


using namespace std;
long long n;
long long a[5000001],b[500001],c[500001];
int main(){
    scanf("%d",&n);
    a[0]=1;
    b[0]=1;
    long long la=1;
    long long lb=1;
    for(long long i=0;i<n-1;i++){
       long long mx=max(la,lb);
       for(long long k=0;k<lb;k++){
        c[k]=b[k];
       }
       long long lc=lb;
       for(long long j=0;j<mx;j++){
        b[j]=a[j]+b[j];
        if(b[j]>=10){
            b[j]-=10;
            b[j+1]+=1;
            lb+=1;
           }
       }
       for(long long g=0;g<=lc;g++){
        a[g]=c[g];
       }
    } 
    long long f=1;
        for(long long i=lb-1;i>=0;i--){
        if(b[i]==0&&f){
            lb--;
        }else{
            f=0;
        }
    }
    for(long long i=lb-1;i>=0;i--){
        cout<<b[i];
    }
    return 0;
}

by New_hope @ 2022-10-15 21:57:31

@Koshka_Dlq33 可能要加高精


by liumuyvan @ 2022-10-16 16:51:56

他又不是没加高精


by A_chicken_boy @ 2023-08-31 16:45:54

@liumuyvan 赞同


by liumuyvan @ 2023-09-02 13:33:15

居然有人考这个古


|