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

using namespace std;

typedef long long llong;

llong myPow(int base, int power) {
    int basecop = base;
    if (power == 0) return 1;
    while (power > 1) {
        base *= basecop;
        power--;
    }
    return base;
}

llong spec_add(llong cop1, llong cop2) {
    llong wynik = 0;
    int times = 0;
    while (cop1 != 0 || cop2 != 0) {
        int res = cop1%10 + cop2%10;
        wynik += res*myPow(10, times++);
        if (res >= 10) times++;
        cop1 /= 10;
        cop2 /= 10;
    }
    return wynik;
}

int main() {
    llong num;
    std::cin >> num;
    int count = 0;
    int flag = 0;

    /*auto start = std::chrono::steady_clock::now();*/
    for (llong i = 0; i <= num/2; i++) {
        for (llong j = num; j >= i; j--) {
            if (spec_add(i, j) == num) {
                if (i==j) count -= 1;
                count += 2;
                //std::cout << i << " " << j << std::endl;
            }
        }
    }
    std::cout << count << std::endl;

    /*
    auto end = std::chrono::steady_clock::now();
    std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
    */

    return 0;
}