一个MLE,向各位大佬求住

P1255 数楼梯

SIRLYAO @ 2023-04-30 09:38:47

#include<iostream>
using namespace std;
long long len=1,a[5500][5500]; 
long long shu(int k){    
    for(int i=1;i<=len;i++)
        a[k][i]=a[k-1][i]+a[k-2][i];
    for(int i=1;i<=len;i++){
        if(a[k][i]>=10){
            a[k][i+1]+=a[k][i]/10;
            a[k][i]=a[k][i]%10;
            if(a[k][len+1])len++;
        }
    }
}
int main(){
    long long x;
    cin>>x;
    a[1][1]=1; 
    a[2][1]=2;
    for(int i=3;i<=x;i++){
        shu(i);
    }
    for(int i=len;i>=1;i--){
       cout<<a[x][i];
    }
    return 0;
}

by SIRLYAO @ 2023-04-30 09:40:51

悬关,谢谢


by kyrie_lrving1992 @ 2023-04-30 09:42:43

@SIRLYAO 5500肯定炸了呀


by SIRLYAO @ 2023-04-30 09:47:29

@kyrie_lrving1992 请大佬告诉我如何修改,谢谢,已关


by _determination_ @ 2023-04-30 09:48:09

@SIRLYAO 你5000\times5000个longlong那肯定爆啊,改成int


by SIRLYAO @ 2023-04-30 09:49:07

谢谢


by SIRLYAO @ 2023-04-30 09:50:08

过了


by linzijie22 @ 2023-04-30 09:57:03

long long最大好像只能3000多


|