parent
e7db5dc8af
commit
35cf216753
@ -0,0 +1,19 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i, j;
|
||||||
|
for (i = 1;; i++) {
|
||||||
|
int x = i;
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
if ((x - 1) % 5 != 0 || x <= 1) // 扔掉一个是否能分成5份
|
||||||
|
break; // 不符合要求
|
||||||
|
x = (x - 1) / 5 * 4; // 分完第j+1次后剩下的桃子
|
||||||
|
}
|
||||||
|
if (j == 5) { // 符合条件
|
||||||
|
printf("%d", i);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i, j;
|
||||||
|
for (i = 6;; i += 5) {
|
||||||
|
int x = i;
|
||||||
|
for (j = 0; j < 5; j++) {
|
||||||
|
if ((x - 1) % 5 != 0 || x <= 1) // 扔掉一个是否能分成5份
|
||||||
|
break; // 不符合要求
|
||||||
|
x = (x - 1) / 5 * 4; // 分完第j+1次后剩下的桃子
|
||||||
|
}
|
||||||
|
if (j == 5) { // 符合条件
|
||||||
|
printf("%d", i);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// 倒推
|
||||||
|
int x; // 目前计算出的原来桃子的总数量
|
||||||
|
int i = 0;
|
||||||
|
int j = 1; // 最后一个猴子分得的桃子数量为4的j倍
|
||||||
|
while (i < 5) {
|
||||||
|
x = 4 * j;
|
||||||
|
for (i = 0; i < 5; i++) {
|
||||||
|
if (x % 4 != 0) { break; }
|
||||||
|
x = (x / 4) * 5 + 1;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
printf("%d\n", x);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in new issue