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

Function solve

CSES/DP/coinCombinations2.cpp:29–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29void solve() {
30 ll n, x; cin >> n >> x;
31 vector<ll> coins(n); cin >> coins;
32
33 vector<ll> prev(x + 1,0);
34 prev[0] = 1;
35
36 for (int idx = 0; idx < n; ++idx) {
37 for (int tar = 1; tar <= x; ++tar) {
38 if (tar - coins[idx] >= 0) (prev[tar] += prev[tar-coins[idx]] % mod) %= mod;
39 }
40 }
41 cout << prev[x] << '\n';
42}
43
44signed main() {
45 ios_base::sync_with_stdio(false),cin.tie(nullptr);

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected