1. Five monkeys divide the peach. In the middle of the night, the first monkey got up first, it divided the peach into five equal piles, one more. So, it ate one, took a bunch; the second monkey got up and looked, only four piles of peaches. So the four piles together, divided into equal five piles, and one more. So, it also ate one, took a bunch of ... A few other monkeys are also divided. Q: How many of these peaches are at least.
Reference answer: First give this pile of Peaches 4, set at this time a total of x peach, finally left a peach. this:
After the first monkey divided after the left: (1-1/5) x= (4/5) X;
The second monkey divided after the left: (1-1/5) 2X;
After the third monkey divided after the left: (1-1/5) 3X;
The fourth monkey divided after the left: (1-1/5) 4X;
The fifth monkey was left after it was divided: (1-1/5) 5x= (1024/3125) X;
To: A= (1024/3125) X;
To make a an integer, X takes a minimum of 3125.
Minus the plus 4, so there are at least 3,121 of these peaches.
Java programming implementations:
public class Tao {public
static void Main (string[] args) {
int monkey=1;//number of monkeys to divide peach number
int peaches=1;//Peach
int peach=1;//The total number of points per peach
//cycle to give each monkey a peach while
(monkey<=5)
{
//If the success of the Peach if
(peach%5==1&& peach/5!=0)
{
//The total number of peach can be divided into the present 4/5
peach= (PEACH/5);
Replace a monkey
monkey++;
}
If it fails, the peach can be divided by the number of Peaches added 1
else
{
peaches++;
peach=peaches;
Monkey=1;
}
}
System.out.println ("The minimum number of Peaches is:" +peaches);}
}
Programming section for original, algorithmic reference link: http://blog.csdn.net/v_july_v/article/details/6803368