Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int dp[1000000];
- const int MOD = 1e9 + 7;
- int p(int i){
- if(i==0){
- return 1;
- }
- if(dp[i]!=-1){
- return dp[i];
- }
- int result=0;
- for(int j=1; j<=6; j++){
- if(i-j>=0){
- result+=p(i-j);
- result %= MOD;
- }
- }
- dp[i]=result;
- return result;
- }
- int main()
- {
- int n;
- cin>>n;
- for(int i=0; i<=n; i++){
- dp[i]=-1;
- }
- cout<<p(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement