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 <array>
#include <cstdio>
#include <cstring>

constexpr size_t ARRAY_LEN = 25;

int variants(char digit) {
    return digit - '0' + 1;
}

int variantsTens(char *digits) {
    if (digits[0] != '1' || digits[1] == '\0')
    {
	  return 0;
    }
    return 19 - (10 + (digits[1] - '0'));
}

int main()
{
	char notsum[ARRAY_LEN];
	std::array<unsigned long long, ARRAY_LEN> partial;

	partial.fill(1);

	scanf("%s", notsum);

	for (int i = strlen(notsum)-1; i >= 0; --i)
	{
		partial[i] = variants(notsum[i]) * partial[i+1];
		fprintf(stderr, "partial[%d] = %llu * %d\n", i, partial[i+1], variants(notsum[i]));
		partial[i] += partial[i+2] * variantsTens(notsum+i);
	      fprintf(stderr, "partial[%d] += %llu * %d\n", i, partial[i+2], variantsTens(notsum+i));
	}

	printf("%llu\n", partial[0]);

	return 0;
}