百钱买百鸡
package com.hanqi; public class baiqianmaibaiji { public static void main(String[] args) { // TODO 自动生成的方法存根 //100/5=20只公鸡 //100/3 取整为33只母鸡 //100*3=300只小鸡 最多100只 for (int i = 0; i <=20; i++) { for (int j = 0; j <= 33; j++) { for (int k = 0; k <=100; k++) { if((i+j+k)==100) { if(5*i+3*j+k/3==100) { if(k%3==0) { System.out.println("公鸡"+i+"只 母鸡"+j+"只 "+"小鸡"+k+"只");
}
}
}
}
}
}
}
}