您的位置:首页 > 其它

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();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: