题解 | #百钱买百鸡问题#
百钱买百鸡问题
https://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b
解三元一次方程组可以得出三种鸡的数量关系。。。
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int count = sc.nextInt();
int x;
int y;
int z;
for (int i = 0; i <= 100; i += 4) {
x = i;
y = 25 - 7 * x / 4;
z = 100 - x - y;
if (x + y + z == 100 && z >= 0 && y >= 0) {
System.out.println(x + " " + y + " " + z);
}
}
}
}