2008-01-18

Monkey And Peach

On The Beach Has Pile Of Peach , Five Monkeys Divide. The First Monkey Divides Into Equally This Pile Of Peach Five , But More Than A Peach ,This Monkey Throws Away Much One Into The Sea ,Having Taken One Portion Of Five Peach Away .The Second Monkey Equally Divides Into The Peach Five Which Is Left Over , Also More Than A Peach , It Has Thrown Away Much One Into The Sea , Took Away One Portion ,Similarly . The Third , The Fourth , The Fifth Monkey Are All Done By Such . Question , How Many Peach On The Beach Most Little Has In Originally ?

main( )
{
 int i,m,j,k,count;
 for(i=4;i<10000;i+=4)
 {
  count=0;
  m=i;
  for(k=0;k<5;k++)
   {
     j=i/4*5+1;
     i=j;
     if(j%4==0)
     count++;
     else
     break;
   }
  i=m;
  if(count==4)
   {
    printf("%d\n",count);
     break;
   }
 }
}

No comments: