Untitled

mail@pastecode.io avatarunknown
plain_text
2 months ago
737 B
1
Indexable
Never
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
using namespace std;

bool
solve (int n, vector < int >arr)
{
  if (n == 0)
    return true;

  for (int i = 0; i < arr.size (); i++)
    {
      int x = n - arr[i];
      if (solve (x, arr) == true)
	return true;
    }
  return false;
}

int
main ()
{
  cout << solve (7, {2, 4});
  return 1;
}