海滩上有一堆桃子,m只猴子来分。第一只猴子把这堆桃
//平均分为m份,多了一个,把多的一个扔到海里,拿走了一份。
//第二只猴子把剩下的桃子又平均分为m份,多了一个,丢
//入海里,拿走了一份……第三第四……第m只猴字都这样操作,
//请问海滩上原来最少有多少个桃子?
//输入:猴子个数m(3<=m<=9) 输出:原来最少有多少个桃子*/
/*
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int peach = 0;
int i = 0;
int n = 0;
int j = 0;
int rest = 0;
int count = 0;
for(i = 4; i < 10000; i += 4)
{
rest = i;
count = 0;
for(j = 0; j < 5; j++)
{
peach = rest / 4 * 5 + 1;
rest = peach;
if(peach%4 == 0)
{
count++;
}
else
{
break;
}
}
if(count == 4)
{
printf("桃子总数为%d\n", peach);
break;
}
}
return 0;
}
*/
海滩上有一堆桃子,m只猴子来分
最新推荐文章于 2024-04-23 09:29:48 发布