Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
odws
顺序表的实现——静态分配
Conjuntos - Contar caracteres únicos
Test 16(2020)
BinTraversal
Smalllest subarray wiith sum greater than x
String match with test
დიოფანტეს განტოლება
Vec+Mem+Adv_11
Gauss v1.1
Please log in to post a comment.