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
parallel_for_each
Vectores - insertar ordenado e imprimir
26 და 28 მარტს დამუშავებული
Good morning
Sangharsh vhawale
bmp_lb
Scope guarding
search_n algorithm
HashConPar
semiprog.cpp