about summary refs log tree commit diff
path: root/day17.cc
blob: 8d5540713610b4f7c57d2f033faf4337932e7ff6 (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
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int
main()
{
	int d;
	cin >> d;

	vector<int> v{0};
	v.reserve(2018);
	for (int i = 1; i <= 2017; i++) {
		rotate(begin(v), begin(v) + d % size(v), end(v));
		v.push_back(i);
	}

	long p2;
	for (long l = 1, p = 0; l < 50'000'000; p = (p + 1 + d) % ++l)
		if (p == 0)
			p2 = l;

	cout << v[0] << endl << p2 << endl;	// 1306 20430489
}