能说一下你这样做的思路吗?感觉有点怪异
不是应该假设共有X个桃
第一天:剩余 X/2-1
第二天:剩余 (X/2-1)/2-1
.
.
.
为什么初始值j设置为1呢?
程序代码:#include<stdio.h>
#include <stdlib.h>
int main()
{
int peach = 2;
int rest;
int day = 9;
while(1)
{
rest = peach;
for(int i = 0;i<day;i++)
{
rest = rest/2-1;
}
if(rest == 1)
break;
peach+=2;
}
printf("猴子第一天一共摘了%d个桃子\n",peach);
return 0;
}
