You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/GESP/New_WuHouFenTao_1.cpp

21 lines
710 B

1 year ago
#include <bits/stdc++.h>
using namespace std;
1 year ago
// 5只猴子需要多少个桃子3121
//
// 6只猴子
1 year ago
int main() {
1 year ago
for (int i = 6;; i += 5) { // 逐个尝试有i个桃子
int x = i; // 拷贝出来,防止错误的修改
int j;
for (j = 0; j < 5; j++) { // 尝试5个猴子分5回
1 year ago
if ((x - 1) % 5 != 0 || x <= 1) // 扔掉一个是否能分成5份
break; // 不符合要求
1 year ago
x = (x - 1) * 4 / 5; // 分完第j+1次后剩下的桃子
1 year ago
}
if (j == 5) { // 符合条件
printf("%d", i);
exit(0);
}
}
return 0;
1 year ago
}