43 lines
638 B
C++
43 lines
638 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
typedef unsigned long long ull;
|
|
|
|
ull getn(int i, ull n) {
|
|
static map<pair<int, ull>, ull> m;
|
|
if (m.contains({i, n})) {
|
|
return m[{i, n}];
|
|
}
|
|
|
|
ull ret;
|
|
if (i == 0) {
|
|
ret = 1;
|
|
} else if (n == 0) {
|
|
ret = getn(i - 1, 1);
|
|
} else {
|
|
int nd = log10(n) + 1;
|
|
if (nd % 2 == 0) {
|
|
ull l = pow(10, nd / 2);
|
|
ret = getn(i - 1, n % l) + getn(i - 1, n / l);
|
|
} else {
|
|
ret = getn(i - 1, n * 2024);
|
|
}
|
|
}
|
|
|
|
m[{i, n}] = ret;
|
|
return ret;
|
|
}
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(0);
|
|
cin.tie(0);
|
|
|
|
int n;
|
|
ull ret = 0;
|
|
while (cin >> n) {
|
|
ret += getn(75, n);
|
|
}
|
|
|
|
cout << ret << '\n';
|
|
}
|