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


unsigned int countKL(unsigned int n, unsigned int x);

unsigned int countL(unsigned int rest, unsigned int k);

int main() {
    unsigned int n;
    unsigned int result = 0;

    std::cin >> n;

    for (unsigned int x = 1; x * x <= n; x++) {
        result += countKL(n, x);
        if (x * x != n) {
            result += countKL(n, n / x);
        }
    }
    std::cout << result << std::endl;
    return 0;
}

unsigned int countKL(unsigned int n, unsigned int x) {
    unsigned result = 0;
    if (n % x == 0) {
        unsigned int rest = n / x - 1;
        for (unsigned int y = 2; y * y <= rest; y++) {
            if (rest % y == 0) {
                result += countL(rest, y);
                if (y * y != rest) {
                    result += countL(rest, rest / y);
                }
            }
        }
    }
    return result;
}

unsigned int countL(unsigned int rest, unsigned int k) {
    return k > 1 && rest / k - 1 > 1 ? 1 : 0;
}