import java.util.ArrayList;
import java.util.List;
public class selection {
private static int[] numbers= { 1, 2, 4, 8, 16, 32, 64, 128, 250, 250, 250, 250, 250, 250, 250 };
private static int[] sumsum= new int[numbers.length];
private static int sum= 1759;
private static void solution(List<Integer> solution) {
System.out.println(solution);
}
private static void solve(int[] numbers, int i, int sum, List<Integer> solution) {
if (sum == 0)
solution(solution);
else
for (; i < numbers.length && sumsum[i] >= sum; i++) {
if (numbers[i] <= sum) {
solution.add(0, numbers[i]);
solve(numbers, i+1, sum-numbers[i], solution);
solution.remove(0);
}
}
}
public static void main(String[] args) {
for (int s= 0, i= numbers.length; --i >= 0; ) {
sumsum[i]= numbers[i]+s;
s+= numbers[i];
}
solve(numbers, 0, sum, new ArrayList<Integer>());
}
}