
排列組合 DP
#include<bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;
const int MOD = 1e9+7;
int dp[1000005];
void mod(int &x){
if(x >= MOD) x -= MOD;
}
signed main(){
fastio;
int n; cin>>n;
dp[0] = 1;
for(int i=1;i<=n;i++){
for(int j=6;j>=1;j--){
if(i-j >= 0) dp[i] += dp[i-j];
mod(dp[i]);
}
}
cout<<dp[n]<<"\n";
return 0;
}

發佈留言