advent-of-code/2024/11/main-1.cpp
2024-12-10 21:27:18 -08:00

36 lines
609 B
C++

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
vector<ull> stones;
while (cin >> n) {
stones.push_back(n);
}
for (int i = 0; i < 75; i++) {
for (int x = 0; x < stones.size(); x++) {
if (stones[x] == 0) {
stones[x] = 1;
} else {
int nd = log10(stones[x]) + 1;
if (nd % 2 == 0) {
ull l = pow(10, nd / 2);
stones.insert(stones.begin() + x + 1, stones[x] % l);
stones[x] /= l;
x++;
} else {
stones[x] *= 2024;
}
}
}
}
cout << stones.size() << '\n';
}