Advertisement
david12457899

CSES dice combinations

May 13th, 2021
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2.  
  3. const int max = 1000000007;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     std::cin >> n;
  9.     std::vector<long long int> dp(n + 1, 0);
  10.  
  11.     dp[0] = 1;
  12.  
  13.     for (int i = 1; i <= n; i++)
  14.     {
  15.         for (int j = 1; j <= 6; j++)
  16.         {
  17.             if (i - j >= 0)
  18.             {
  19.                 dp[i] = (dp[i] + dp[i - j]) % max; // modulu max because the number can be over 10e+7
  20.             }
  21.         }
  22.     }
  23.  
  24.     std::cout << dp[n];
  25.  
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement