1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
#define ll long long

ll n;
ll pre[1000];
ll res = 0;

void prepare(){
    for (int i = 0; i <= 19; i++){
        for (int k = 0; k <= 9; k++){
            int l = i-k;
            if (l >= 0 && l <= 9)
                pre[i]++;
        }
    }
}

ll go(ll N){
    if (N == 0)
        return 1;
    ll tmp = 0;
    // odklejam jedna
    int x = (N%10);
    tmp = go(N/10) * pre[x];
    // odklejam dwie
    if (N >= 10){
        x = (N%100);
        tmp += go(N/100) * pre[x];
    }
    return tmp;
}

int main(){
    std::ios_base::sync_with_stdio(0); std::cin.tie(NULL);
    std::cin >> n;
    prepare();
    res = go(n);
    std::cout << res << "\n";
}