diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-22 08:54:33 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-22 08:54:33 +0100 |
| commit | 633104e38f45250289ab245ec16967163b308218 (patch) | |
| tree | 5cb43a1ef46b84289969e31a1486e2cdfd40f67f /2024/22/day22a.cpp | |
| parent | 6cbc9b03a74bcb295271de36256318d6945a2963 (diff) | |
| download | aoc-633104e38f45250289ab245ec16967163b308218.tar.gz aoc-633104e38f45250289ab245ec16967163b308218.zip | |
Day 22 2024, but it's slow
Diffstat (limited to '2024/22/day22a.cpp')
| -rw-r--r-- | 2024/22/day22a.cpp | 32 |
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> | ||
| 12 | using namespace std; | ||
| 13 | |||
| 14 | int64_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 | |||
| 22 | int 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 | } | ||
