题解 | #百钱买百鸡问题#
百钱买百鸡问题
http://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b
import java.util.*;
public class Main {
public static void main(String []args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextLine()) {
sc.nextLine();
calculate();
}
}
public static void calculate() {
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 33; j++) {
for (int k = 100; k > 0; k--) {
if (i + j + k == 100 && k % 3 == 0 && i * 5 + j * 3 + k / 3 == 100) {
System.out.println(i+" "+j+" "+k);
}
}
}
}
}
}