Advertisement
LEGEND2004

Dice Combinations

Aug 22nd, 2023
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. const int INF = 1e9;
  6. const int mod = 1e9 + 7;
  7. const int N = 1e6 + 5;
  8. int dp[N];
  9.  
  10. signed main()
  11. {
  12.     int n;
  13.     cin >> n;
  14.     dp[0] = 0;
  15.     for(int i = 1; i <= 6; i++)
  16.         dp[i] = 1;
  17.  
  18.     for(int i = 1; i <= n; i++){
  19.         for(int j = 1; j <= 6; j++){
  20.             if(i >= j)
  21.                 dp[i] += dp[i - j];
  22.             dp[i] %= mod;
  23.         }
  24.     }
  25.     cout << dp[n] << endl;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement