MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / solve

Function solve

CSES/DP/DiceCombination.cpp:29–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27ostream &operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) { cout << it << " "; } return ostream; }
28
29void solve() {
30 int n; cin >> n;
31 vector<ll> dp(n+1,0);
32 dp[0] = 1;
33 dp[1] = 1;
34 for (int i = 2; i <= n; ++i) {
35 ll ways = 0;
36 for (int k = 1; k <= 6; ++k) {
37 if ((i-k) >= 0) {
38 (ways += dp[i-k]) %= mod;
39 }
40 }
41 (dp[i] = ways) %= mod;
42 }
43 cout << dp[n] % mod << '\n';
44}
45
46signed main() {
47 ios_base::sync_with_stdio(false),cin.tie(nullptr);

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected