文章
1
粉丝
68
获赞
6
访问
6.6k
import java.util.*;
public class Main {
/*
Time Limit: 1000 ms
Memory Limit: 256 mb
给出三个杯子的容量ABC , 其中刚开始时C杯是满的,AB是空的。
现在在保证不会有漏水的情况下进行如下操作:
将一个杯子x的水倒到另一个杯子y中,如果x空了或者y满了就停止(满足其中一个条件才停下)
现问C中水量有多少种可能性(A,B,C为非负整数)
60% case A,B,C<=100
100% case A,B,C<=4000
C初始为满容量,可以随意次数地互相倒水,问C最终能有多少种水量可能性
PS:需要注意内存限制,不能直接开大数组
*/
static int ans = 0;
public static void main(String[] args) {
//输入
Scanner input = new Scanner(System.in);
while (input.hasNextInt()) {
ans = 0;
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
if (c == 0) {
System.out.println(1);
continue;
}
if (a == 0 && b == 0) {
System.out.println(1);
continue;
}
if (a == 0 || b == 0) {
System.out.println(2);
...
登录后发布评论
暂无评论,来抢沙发