1 public class test 2 { 3 public static void main(String[] args) 4 { 5 Vectorv = new Vector<>(); 6 v.add(1); 7 v.add(2); 8 v.add(5); 9 Vector solution = new Vector<>();10 Scanner input = new Scanner(System.in);11 int dst = input.nextInt();12 System.out.println(CoinsCombination(v, solution, 0, 0, dst));13 input.close();14 } 15 16 public static int CoinsCombination(Vector v, Vector solution, int start, int sum, int dst)17 {18 if(dst <= 0)19 return 0;20 if(sum == dst)21 {22 System.out.println(solution.toString());23 return 1;24 }25 if(sum > dst)26 return 0;27 28 int count = 0;29 for(int i = start; i < v.size(); i++)30 {31 solution.add(v.get(i));32 sum += v.get(i);33 count += CoinsCombination(v, solution, i, sum, dst);34 solution.remove(solution.size() - 1);35 sum -= v.get(i);36 }37 38 return count;39 }40 }