'commit'
This commit is contained in:
21
GESP/资料/New_WuHouFenTao_1.cpp
Normal file
21
GESP/资料/New_WuHouFenTao_1.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
// 5只猴子,需要多少个桃子3121
|
||||
//
|
||||
// 6只猴子,
|
||||
int main() {
|
||||
for (int i = 6;; i += 5) { // 逐个尝试有i个桃子
|
||||
int x = i; // 拷贝出来,防止错误的修改
|
||||
int j;
|
||||
for (j = 0; j < 5; j++) { // 尝试5个猴子分5回
|
||||
if ((x - 1) % 5 != 0 || x <= 1) // 扔掉一个是否能分成5份
|
||||
break; // 不符合要求
|
||||
x = (x - 1) * 4 / 5; // 分完第j+1次后剩下的桃子
|
||||
}
|
||||
if (j == 5) { // 符合条件
|
||||
printf("%d", i);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user