package margusmartseppcode.From_30_to_39; public class Problem_31 { public static void main(String[] args) { int target = 200, coins[] = { 1, 2, 5, 10, 20, 50, 100, 200 }; int ways[] = new int[target + 1]; ways[0] = 1; for (int coin : coins) for (int i = coin; i < target + 1; i++) ways[i] += ways[i - coin]; System.out.println(ways[target]); } }
No comments:
Post a Comment