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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <queue>
using namespace std;

long long number0;
queue <int> podz;
long long the_result = 0;

long long how_many_ways(queue <int> podzial)
{
    long long result = 1;
    int frag;
    while (podzial.size() > 0)
    {
        frag = podzial.front();
        podzial.pop();
        if (frag >= 19)
        {
            result *= 0;
        }
        else if (frag <= 9)
        {
            result *= (frag + 1);
        }
        else
        {
            result *= (19 - frag);
        }
    }
    return result;
}

void rec_generator(queue <int> to_split, queue <int> acc)
{
    if (to_split.size() == 0)
    {
        the_result += how_many_ways(acc);
    }
    else if (to_split.size() == 1)
    {
        int el = to_split.front();
        to_split.pop();
        queue <int> new_acc = acc;
        new_acc.push(el);
        rec_generator(to_split, new_acc);
    }
    else
    {
        int el = to_split.front();
        to_split.pop();
        queue <int> new_acc = acc;
        new_acc.push(el);
        rec_generator(to_split, new_acc);
        if (to_split.front() != 0)
        {    
            el = el + 10 * to_split.front();
            to_split.pop();
            new_acc = acc;
            new_acc.push(el);
            rec_generator(to_split, new_acc);
        }
    }
}

int main()
{
    cin>>number0;
    while (number0 > 0)
    {
        podz.push(number0 % 10);
        number0 /= 10;
    }
    queue <int> empty;
    rec_generator (podz, empty);
    cout << the_result << endl;
}