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
#include <iostream>

using namespace std;

int ile(long long int n)
{
    int pom = n%100;
    if(pom==0 || pom>18) return 0;
    return (19-pom);

}

int get_dig(int n)
{
    int pom = 0;
    while(n){
        pom++;
        n /= 10;
    }
    return pom;
}

int main()
{
    long long int n;
    cin >> n;

    int dig = get_dig(n);
    if(dig==1 || n==0){
        cout << n+1 << endl;
        return 0;
    }

    long long int t[dig+1];
    int x, y;
    x = n%10;
    t[0] = 0;
    t[1] = x+1;

    y = ile(n);
    n /= 10;
    x = n%10+1;
    t[2] = (t[1]*x)+y;
    //cout<<y<<endl;
    for(int i=3; i<=dig; ++i){
        y = ile(n);
        n /= 10;
        x = n%10+1;
        t[i] = (t[i-1]*x)+(t[i-2]*y);
    }
    //for(int i=1; i<=dig; ++i) cout<<t[i]<<" ";
    cout << t[dig] << endl;


    return 0;
}