aboutsummaryrefslogtreecommitdiff
path: root/2024/22/day22a.cpp
blob: b2adfdc6e2a623f61facd9dd7729b461edadd334 (plain)
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
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>
#include <queue>
#include <ranges>
#include <set>
#include <sstream>
#include <string>
#include <string_view>
#include <vector>
using namespace std;

int64_t next(int64_t n) {
	constexpr int64_t M = 16777216;
	n = ((n*64) ^ n) % M;
	n = ((n/32) ^ n) % M;
	n = ((n*2048) ^ n) % M;
	return n;
}

int main() {
	int64_t s;
	int64_t tot = 0;
	while (cin >> s) {
		for (int i = 0; i < 2000; i++)
			s = next(s);
		tot += s;
	}
	cout << tot << endl;
	return 0;
}

Generated with cgit - Back to sebastiano.tronto.net