From 633104e38f45250289ab245ec16967163b308218 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 22 Dec 2024 08:54:33 +0100 Subject: Day 22 2024, but it's slow --- 2024/22/day22a.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 2024/22/day22a.cpp (limited to '2024/22/day22a.cpp') 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 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +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; +} -- cgit v1.3