1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <map>

std::map<uint64_t, uint64_t> M;
uint64_t f(uint64_t n) {
    if (n == 0) return 1;
    auto it = M.find(n);
    if (it != M.end()) return it->second;
    uint64_t a = n%10+1;
    uint64_t b = n%100;
    if (b < 10 || b > 18) b = 0;
    else b = 19-b;
    return M[n] = f(n/10) * a + f(n/100) * b;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    uint64_t n;
    std::cin >> n;
    std::cout << f(n) << std::endl;
    return 0;
}