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
#include <iostream>
using namespace std;

int oneNumberCombination(int n)
{
	if (n < 10)
		return n + 1;
	else
		return (18 - n) + 1;
}

unsigned long long allCombination(unsigned long long n)
{
    if (n == 0)
        return 1;
    else
    {
        int lastDigit = n % 10;
        int secondDigit = (n / 10) % 10;
        if (secondDigit == 1)
        {
            return (oneNumberCombination(lastDigit) * allCombination(n / 10))
                + (oneNumberCombination(10 + lastDigit) * allCombination(n / 100));
        }
        else
        {
            return oneNumberCombination(lastDigit) * allCombination(n / 10);
        }
    }
}

int main()
{
    unsigned long long n, result;
    cin >> n;
    result = allCombination(n);
    cout << result;
}