UVa 10465 HomerSimpson
2013-07-08 21:15
183 查看
/*UVa 10465 HomerSimpson*/ import java.util.Arrays; import java.util.Scanner; class HomerSimpson { static final int MAXN = 10005; static int[] d = new int[MAXN]; static int t; static int[] w = new int[2]; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { Arrays.fill(d, -1); d[0] = 0; w[0] = scanner.nextInt(); w[1] = scanner.nextInt(); t = scanner.nextInt(); for (int i = 0; i < 2; i++) { for (int j = w[i]; j <= t; j++) { if (d[j - w[i]] != -1) { d[j] = Math.max(d[j], d[j - w[i]] + 1); } } } int cn = 0; for (int i = t; i >= 0; i--) { if (d[i] != -1) break; cn++; } System.out.printf("%d", d[t - cn]); if (cn > 0) System.out.printf(" %d\n", cn); else System.out.println(); } } }
相关文章推荐
- UVA 10465 Homer Simpson
- UVa 10465 - Homer Simpson
- UVA 10465 Homer Simpson
- UVA 10465 Homer Simpson
- uva 10465 Homer Simpson
- uva 10465 Homer Simpson
- UVA - 10465 Homer Simpson
- UVA 10465 Homer Simpson
- UVa 10465 - Homer Simpson
- UVa 10465 - Homer Simpson DP 完全背包
- Uva 10465 — Homer Simpson
- uva 10465 Homer Simpson
- 10465 - Homer Simpson
- 10465 - Homer Simpson
- uva 10465 Homer Simpson
- The Math Trick Behind MP3s, JPEGs, and Homer Simpson’s Face
- UVa 10465 - Homer Simpson 背包
- uva 10465 Homer Simpson
- uva 10465 Homer Simpson
- uva 10465 (完全背包)