猴子分香蕉
package cn.itlaobing.C_2018;
public class Monkey_fen_banana {
/*
* 5只猴子
* 1 5堆 余1
* 2 5堆 余2
* 3 5堆 余3
* 4 5 4
* 5 5 0
* sum
* a(sum=a*5+1) b(a*4=b*5+2) c(b*4 = c*5+3) d(c*4 = d*5+4 ) e(d*4 = 5*e)
*以上是我的大致思想
*/
public static void main(String[] args) {
for(int i=0;i<10000;i++){
int tep=i;
if(tep%5==1){
tep=tep-tep/5-1;
if(tep%5==2){
tep=tep-tep/5-2;
if(tep%5==3){
tep=tep-tep/5-3;
if(tep%5==4){
tep=tep-tep/5-4;
if(tep%5==0&&tep>0){
System.out.println(i);
}
}
}
}
}
}
}
}