UVa 357 - Let Me Count The Ways
2013-06-27 20:24
465 查看
/*UVa 357 - Let Me Count The Ways*/ import java.util.Scanner; class Main { public static void main(String[] args) throws Exception { int arr[] = { 1, 5, 10, 25, 50 }; long dp[] = new long[30001]; dp[0] = 1; for (int j = 0; j < 5; j++) { for (int i = 1; i < 30001; i++) { if (i >= arr[j]) dp[i] += dp[i - arr[j]]; } } Scanner scanner = new Scanner(System.in); while (scanner.hasNextInt()) { int n = scanner.nextInt(); if (dp == 1) { System.out.println("There is only 1 way to produce " + n + " cents change."); } else { System.out.println("There are " + dp + " ways to produce " + n + " cents change."); } } } }
相关文章推荐
- UVa:357 Let Me Count The Ways
- uva 357 Let Me Count The Ways
- UVA 357 Let Me Count The Ways
- UVA 357 - Let Me Count The Ways
- uva 357 Let Me Count The Ways (DP)
- UVA 357 Let Me Count The Ways
- uva 357 let me count the ways
- UVA 357 - Let Me Count The Ways
- UVA 357 - Let Me Count The Ways
- UVA 357 Let Me Count The Ways Problem(动态规划 硬币)
- uva 357 - Let Me Count The Ways
- UVa 357 - Let Me Count The Ways
- UVA - 357 Let Me Count The Ways(完全背包)
- 【解题报告】uva357_Let Me Count The Ways(让我来数数方案, dp, 完全背包)
- UVA 357 - Let Me Count The Ways
- uva_357 Let Me Count The Ways
- UVA 357 Let Me Count The Ways(全然背包)
- UVa 357 - Let Me Count The Ways 背包
- uva 357 Let Me Count The Ways(01背包)
- UVA - 357 Let Me Count The Ways