import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static boolean subsetSum(int []arr, int ind, int target){
if(target==0)
return true;
if(ind==0)
return arr[0]==target;
boolean notTake=subsetSum(arr,ind-1,target);
boolean take=false;
if(arr[ind]<=target)
take=subsetSum(arr,ind-1,target-arr[ind]);
return take || notTake;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String str[]=sc.nextLine().split(" ");
int[] arr = Arrays.stream(str).mapToInt(Integer::parseInt).toArray();
int target=sc.nextInt();
System.out.println(subsetSum(arr, arr.length-1, target));
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: