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

using namespace std;

int t[20], ab[20], dl;
string liczba;

long long go(int i, int f)
{
  if (i >= dl || i + f > dl)
    return 1;
  //cout << "go(" << i << "," << f << ") ";
  int p;
  if (f == 2 && i + 1 < dl)
    p = ab[i] * 10 + ab[i + 1];
  else
    p = ab[i];
  //cout << "p=" << p << endl;
  long long lewo = 0, prawo = 0, kolejny = i + f;
  //cout << "w lewo: ";
  lewo = go(kolejny, 1) * t[p];

  if (f == 1 && kolejny < dl - 1 && ab[i] == 1)
  {
    //cout << "w prawo " << kolejny << ".";
    bool samezera = true;
    for (int j = kolejny; j < kolejny + 2; j++)
      if (ab[j] != 0)
        samezera = false;
    if (!samezera)
      prawo = go(kolejny, 2) * t[p];
  }
  return (lewo + prawo);
}

int main()
{
  long long res = 0;
  for (int k = 0; k <= 18; k++)
  {
    for (int a = 0; a < 10; a++)
      for (int b = a; b < 10; b++)
        if (a + b == k)
          t[k]++;
    if (k % 2 == 1)
      t[k] = t[k] * 2;
    else
      t[k] = t[k] * 2 - 1;
    //cout << k << ":" << t[k] << " ";
  }
  //cout << endl;
  cin >> liczba;
  dl = liczba.size();
  for (int i = 0; i < dl; i++)
    ab[i] = liczba[i] - 48;
  res = go(0, 1);
  //cout << res << endl;
  if (liczba[0] == '1')
    res += go(0, 2);

  cout << res;
}