求助.....

P1255 数楼梯

shenyibo12200 @ 2024-07-22 15:24:01

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
ull m,n,num[100000];
ull lmp(ull m,ull n){
    ull num[100000];
    for(ull i=0;i<m;i++){
        num[i]=i+1;
    }
    ull dp[100000];
    dp[0]=1;
    for(ull i=0;i<=n;i++){
        for(ull j=0;j<m;j++){
            if(i-num[j]>=0){
                dp[i]+=dp[i-num[j]];
            }
        }
    } 
    return dp[n];
}
//void get(int a[],int n){
//  for(int i=0;i<n;i++){
//      cin>>a[i];
//  }
//}
int main(){
    cin>>n;
    //get(num,m);
    cout<<lmp(2,n)<<endl;
    return 0;
}

by Into_the_Abyss @ 2024-07-22 15:32:41

@shenyibo12200 首先要开高精


by Into_the_Abyss @ 2024-07-22 15:40:46

@shenyibo12200 其次...

你这个dp也不对啊

应该是dp[i]=dp[i-1]+dp[i-2]


by shenyibo12200 @ 2024-07-22 17:03:45

@Into_the_Abyss 感谢


|