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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int triplets = 0;
    for (int a = 1; a*a <= n; a++) {
        if (n % a != 0) continue;
        int d = a;
        for(int b = 2; b*b <= n-d; b++) {
            if ((n - d) % b != 0) continue;
            if (b % d == 0 && d < b && b < n - d - b) triplets++;
            if (b*b == n-d) break;
            if (((n-d)/b) % d == 0 && d < (n-d)/b && (n-d)/b < n - d - (n-d)/b) triplets++;
        }
        if (a*a != n) {
            d = n/a;
            for(int b = 2; b*b <= n-d; b++) {
                if ((n - d) % b != 0) continue;
                if (b % d == 0 && d < b && b < n - d - b) triplets++;
                if (b*b == n-d) break;
                if (((n-d)/b) % d == 0 && d < (n-d)/b && (n-d)/b < n - d - (n-d)/b) triplets++;
            }
        }
    }
    cout << triplets << '\n';
    return 0;
}