aboutsummaryrefslogtreecommitdiff
path: root/2024/22/day22a.cpp
diff options
context:
space:
mode:
Diffstat (limited to '2024/22/day22a.cpp')
-rw-r--r--2024/22/day22a.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/2024/22/day22a.cpp b/2024/22/day22a.cpp
new file mode 100644
index 0000000..b2adfdc
--- /dev/null
+++ b/2024/22/day22a.cpp
@@ -0,0 +1,32 @@
1#include <algorithm>
2#include <cstdint>
3#include <iostream>
4#include <map>
5#include <queue>
6#include <ranges>
7#include <set>
8#include <sstream>
9#include <string>
10#include <string_view>
11#include <vector>
12using namespace std;
13
14int64_t next(int64_t n) {
15 constexpr int64_t M = 16777216;
16 n = ((n*64) ^ n) % M;
17 n = ((n/32) ^ n) % M;
18 n = ((n*2048) ^ n) % M;
19 return n;
20}
21
22int main() {
23 int64_t s;
24 int64_t tot = 0;
25 while (cin >> s) {
26 for (int i = 0; i < 2000; i++)
27 s = next(s);
28 tot += s;
29 }
30 cout << tot << endl;
31 return 0;
32}

Generated with cgit - Back to sebastiano.tronto.net