题解 | #百钱买百鸡问题#
百钱买百鸡问题
http://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
// 鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡
//x+y+z=100
//15x+9y+z=300;
//x最多等于14
for (int x = 0; x <= 14; x++) {
//如果y可以被整除
if((100-7*x) % 4 == 0){
//拿到y值
int y = (100-7*x) / 4;
//已经得到x,y,算出z
int z = 100 - x - y;
System.out.println(x + " " + y + " " + z);
}
}
}
}