fork(1) download
  1. #include <iostream>
  2. #include <array>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. constexpr int MAXCENTS = 100000;
  7.  
  8. array<long long, MAXCENTS + 1> ways;
  9.  
  10. void dp(vector<int> coins, int value)
  11. {
  12. ways.fill(0);
  13. ways[0] = 1;
  14. for (int coin : coins) {
  15. for (int v = coin; v <= value; ++v) {
  16. ways[v] = ways[v - coin] + ways[v];
  17. }
  18. }
  19. }
  20.  
  21. int main()
  22. {
  23. dp({1, 2, 5, 10, 25, 100, 200}, 500);
  24. cout << ways[500] << endl;
  25. return 0;
  26. }
Success #stdin #stdout 0s 4192KB
stdin
Standard input is empty
stdout
2201362