WA求助!!!

P1255 数楼梯

zmhjason @ 2024-01-25 15:12:51

#include <bits/stdc++.h>
using namespace std;
int dp[100002];
int fib(long long x){
    if(dp[x]==0){
        if(x==1||x==2)dp[x]=x;
        else dp[x]=fib(x-1)+fib(x-2);
    }
    return dp[x];
}
int main()
{
    long long a;
    cin>>a;
    cout<<fib(a);
    return 0;
}

代码如上


by SugarKite @ 2024-01-25 15:22:53

高精度,这题会爆longlong


|