fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define file(NAME) if (fopen(NAME".inp", "r")) freopen(NAME".inp", "r", stdin), freopen(NAME".out", "w", stdout)
  6. #define FOR(i, a, b) for (int i = (int) a; i <= (int) b; ++i)
  7. #define FOD(i, a, b) for (int i = (int) a; i >= (int) b; --i)
  8.  
  9. #define all(s) (s).begin(), (s).end()
  10. #define pb push_back
  11. #define ll long long
  12. #define int ll
  13. #define fi first
  14. #define se second
  15. #define pii pair<int, int>
  16.  
  17. const int maxn = 1e6 + 5;
  18. const int N = 505;
  19. const int MOD = 1e9 + 7;
  20.  
  21. int n;
  22. int dp[maxn];
  23.  
  24.  
  25. int calc(int val) {
  26. if (val > n) return 0;
  27. if (val == n) return 1;
  28.  
  29.  
  30. int &ans = dp[val];
  31.  
  32. if (ans != 0) return ans;
  33.  
  34.  
  35. for (int i = 1; i <= 6; ++i) {
  36. ans = (ans + calc(val + i) % MOD) % MOD;
  37.  
  38. }
  39.  
  40. return ans;
  41. }
  42.  
  43.  
  44.  
  45.  
  46. signed main() {
  47. cin.tie(0) -> sync_with_stdio(0);
  48. file("x");
  49.  
  50.  
  51.  
  52. cin >> n;
  53.  
  54.  
  55.  
  56. cout << calc(0);
  57.  
  58. return 0;
  59. }
Success #stdin #stdout 0.01s 12336KB
stdin
123456
stdout
113810539