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

using namespace std;

string add(string a, string b)
{
  int sum;
  string ssum = "", tmp, aa, bb;
  for(int i=1; i <= max(a.size(), b.size()); i++ )
  {
      if(i<=a.size())
        aa = a[a.size()-i];
      else
        aa = "0";
      if(i<=b.size())
        bb = b[b.size()-i];
      else
        bb = "0";

      sum = atoi(aa.c_str()) + atoi(bb.c_str());
      tmp = to_string(sum);
      if(tmp.size()>1)
        swap(tmp[0], tmp[1]);
        ssum += tmp;
  }

  for(int i=0; i<ssum.size()/2; i++)
    swap(ssum[i], ssum[ssum.size()-i-1]);
  return ssum;
}

int main()
{
  unsigned long long int input;
  int counter=0;
  string input2;
  cin >> input;
  input2 = to_string(input);

  for(unsigned long long int i=0; i<=input; i++)
  for(unsigned long long int j=0; j<=input; j++)
      if(add(to_string(i), to_string(j)) == input2)
        counter ++;

  //cout << add("4","18") << endl;
  cout << counter << endl;
  return 0;
}