/*
用200斤大米换苹果和西瓜,四斤大米换一斤苹果,三斤大米换一斤西瓜。苹果和西瓜不能为0,
问有多少种换法,大米必须换完
*/
class Exchange {
public static void main(String[] args) {
int count = 0;
for (int apple = 0; apple < 50; apple++) {
for (int watermelon = 0; watermelon <70; watermelon++) {
if (apple*4 + watermelon*3 == 200 && apple != 0 && watermelon != 0) {
System.out.println(apple + "..." + watermelon);
count++;
}
}
}
System.out.println(count);
}
} |
|