-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path305.cpp
58 lines (46 loc) · 740 Bytes
/
305.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <cstdint>
using namespace std;
int64_t ans[15] = {0};
void _calc();
int main() {
int64_t input;
_calc();
while (cin >> input) {
if ((input != 0) && (input < 14)) {
cout << ans[input] << endl;
}
}
return 0;
}
void _calc() {
int64_t num, bad, pos;
bool success;
for (int64_t k = 1; k < 14; k++) {
num = k + 1;
success = false;
if (k > 1) {
while (!success) {
bad = k;
pos = 0;
while (true) {
pos = ((num + pos) % (k + bad)) + 1;
if ((k < pos) && (0 < bad)) {
bad--;
pos--;
} else {
break;
}
if (bad == 0) {
success = true;
break;
}
}
num++;
}
ans[k] = num;
} else {
ans[k] = 2;
}
}
}