求查错

P1255 数楼梯

已注销&M73*K7U @ 2020-08-07 18:04:56

#include<bits/stdc++.h>
using namespace std;

string gj(string a12,string b12) {
    int a11[2000],b11[2000],sum11[2000],alen1,blen1,slen1;
    string c="";
    memset(a11,0,2000);
    memset(b11,0,2000);
    memset(sum11,0,2000);
    alen1=a12.size();
    for(int i=0; i<alen1; i++) a11[i]=a12[alen1-(i+1)]-48;
    blen1=b12.size();
    slen1=max(alen1,blen1);
    for(int i=0; i<blen1; i++) b11[i]=b12[blen1-(i+1)]-48;
    for(int i=0; i<slen1; i++) {
        sum11[i]+=(a11[i]+b11[i]);
        if(sum11[i]>=10) sum11[i+1]++,sum11[i]-=10;
    }
    if(sum11[slen1]>0) slen1++;
    slen1--;
    for(int i=slen1; i>=0; i--) {
        c+=char(sum11[i]+int('0'));
    }
    return c;
}

int n;
string a[5005];
int main() {
    scanf("%d",&n);
    if(n==0) {
        printf("0");
        return 0;
    }
    a[0]="1",a[1]="1";
    for(int i=2; i<=n; i++) {
        a[i]=gj(a[i-1],a[i-2]);
    }
    cout<<a[n];
    return 0;
}

2、10过不了

输入5000时返回乱码


by CornWorld @ 2020-08-26 09:43:58

啊这 好兄弟


上一页 |