fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. bool check_all_denominations(vector<bool> P, int v, vector<int> x)
  6. {
  7. P[0] = true;
  8.  
  9. for (int i = 1; i <= x.size(); i++)
  10. {
  11. P[x[i]] = true;
  12. }
  13. for (int h = 0; h <= v; h++)
  14. {
  15. bool result = false;
  16. for (int j = 1; j <= x.size(); j++)
  17. {
  18. if (x[j] <= h)
  19. result = result || *P[h-x[j]];
  20. }
  21. P[h] = result;
  22. }
  23. cout << "P: [";
  24. for (int i = 0; i <= P.size(); i++)
  25. {
  26. cout << P[i] + " ,";
  27. }
  28. cout << "]";
  29. return P[v];
  30. }
  31.  
  32. int main() {
  33. vector<int> ints;
  34. ints.push_back(3);
  35. ints.push_back(7);
  36. vector<bool> test;
  37.  
  38. for (int i = 0; i < 70; i++)
  39. {
  40. test.push_back(false);
  41. }
  42. cout << check_all_denominations(test, 40, ints ) ? "True" : "False";
  43. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'bool check_all_denominations(std::vector<bool>, int, std::vector<int>)':
prog.cpp:19:24: error: no match for 'operator*' (operand type is 'std::vector<bool>::reference {aka std::_Bit_reference}')
     result = result || *P[h-x[j]];
                        ^
stdout
Standard output is empty