Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Coin changes
//Title of this code #include <iostream> #include <vector> using namespace std; int num_of_changes(vector<int>& coins, int value) { int t[coins.size() + 1][value + 1]; t[0][0] = 0; for (int i = 1; i < coins.size() + 1; ++i) t[i][0] = 1; for (int i = 1; i < value + 1; ++i) t[0][i] = 0; for (int i = 1; i < value + 1; ++i) { cout << i << " - "; for (int j = 1; j < coins.size() + 1; ++j) { int d = i - coins[j - 1]; t[j][i] = t[j - 1][i]; if (d >= 0) t[j][i] += t[j][d]; cout << t[j][i] << " "; } cout << endl; } return t[coins.size()][value]; } int main() { vector<int> t; t.push_back(2); t.push_back(3); t.push_back(4); int changes = num_of_changes(t, 9); std::cout << "cahnges: " << changes; }
run
|
edit
|
history
|
help
0
<string> Indirect include of <errno.h> with gcc
char strcpy
Get smallest dividers
DP on Trees: Type B (In/out Dp)
check Prime
list_of pair strings
FunTemp
Value equal to index value
congruence modulo equations (together with a simple BigInteger class)
Preference List