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
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

// count pairs (k, l) such that k + kl = m and k, l > 1
ll count2(int m) {
    ll res = 0;

    for (int k = 2; k * k <= m; k++) {
        if (m % k == 0) {
            if (m / k >= 3) {
                res++;
            }

            if (k * k != m && k >= 3) {
                res++;
            }
        }
    }

    return res;
}

// #(a, b, c) such that a < b < c, a + b + c = n and
// (a, b, c) = (a, ka, lka)
ll solve(int n) {
    ll res = 0;

    for (int a = 1; a * a <= n; a++) {
        if (n % a == 0) {
            res += count2(n / a - 1);
            if (a * a != n) {
                res += count2(a - 1);
            }
        }
    }

    return res;
}

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    cout << solve(n) << "\n";
}