blob: 1a6a867b7539726eb80cb543118453f50458816b (
plain) (
blame)
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
|
#include <stdio.h>
#include <stdlib.h>
int main(void) {
static int turns[30000000];
int turn = 1;
int last, next;
scanf("%d,", &last);
while (0 < scanf("%d,", &next)) {
turns[last] = turn;
last = next;
turn++;
}
while (turn != 2020) {
if (turns[last]) {
next = turn - turns[last];
} else {
next = 0;
}
turns[last] = turn;
last = next;
turn++;
}
printf("%d\n", last);
while (turn != 30000000) {
if (turns[last]) {
next = turn - turns[last];
} else {
next = 0;
}
turns[last] = turn;
last = next;
turn++;
}
printf("%d\n", last);
}
|