#include<cstdio>
#include<algorithm>
using namespace std;
bool ok=false;
int num=0;
bool solve(int index){
int res=index*5;
for(int i=0;i<5;i++){
if((res+1)*5%4){
return false;
}
res=(res+1)*5/4;
}
num=res+1;
return true;
}
int main(){
for(int i=1;i<=10000;i++){
ok=solve(i);
if(ok){
printf("%d\n",num);
break;
}
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
for(int i=1;;i++)
{
int k=0,temp=i;
while(k<6)
{
if (5*temp%4==0)
{
k=k+1;
temp = 5*temp/4+1;
cout<<"i="<<i<<" k="<<k<<" temp="<<temp<<endl;
}
else
{
break;
}
}
if(k==6)
{
cout<<temp<<endl;break;
}
}
system("pause");
return 0;
}
bool fun(int num,int n){
int totle = n*5+1;
num--;
if(num<1){
cout<<totle<<endl;
return true;
}
if(totle%4==0){
fun(num,totle/4);
}
else{
return false;
}
}
int main(){
bool right=false;
for(int i=1;i<INT_MAX&&!right;i++){
right = fun(6,i);
}
return 0;
}
/**
* 使用 递归计算
*
* @access global
* @param mixed $num 分椰子的次数
* @param mixed $x 最后每个人分到椰子的个数
* @return void
*/
function test($num,$x)
{
$total = 0;
$total = ($x * 5) +1;
$num--;
if($num < 1)
{
echo $total;
}else
{
test($num,$total);
}
}
test(6,1);
那最少 椰子的个数为 19531个
第一个人给了猴子1个,藏了3124个,还剩12496个;
第二个人给了猴子1个,藏了2499个,还剩9996个;
第三个人给了猴子1个,藏了1999个,还剩7996个;
第四个人给了猴子1个,藏了1599个,还剩6396个;
第五个人给了猴子1个,藏了1279个,还剩5116个;
最后大家一起分成5份,每份1023个,多1个,给了猴子。