公元前五世纪,我国古代数学家张丘建在《算经》一书中提出了“百鸡问题”:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡,问鸡翁、鸡母、鸡雏各几何?

时间:2024-03-05 16:07:43
private static void chickenCount() {
for (int i = 0; i <= 100/5; i++) {
for (int j = 0; j <= (100 - 5 * i)/3; j++) {
int c = (100 - 5 * i - 3 * j) * 3;
if(i + j + c == 100){
System.out.println("公鸡:"+i+",母鸡:"+j+",小鸡:"+c);
}
}
}
}