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

#define LOG(_x_) //std::cerr << _x_ << std::endl
#define TRC(_x_) //LOG(_x_)

void calc(int &count, int a, int n) {
    for (int j = a * 2; j <= n - a - j; j += a) {
        int sk = n - a - j * 2;
        int ek = n - a - j;
        if (ek >= j * 2) {
            if ((ek % j) != 0) {
                ek = ek / j + j;
            }
            LOG("K:" << sk);
            for (int k = ek; k > sk; k -= j) {
                TRC(a << ", " << j << ", " << k);
                if ((k > j) && a + j + k == n) {
                    LOG("F:" << a);
                    count++;
                }
            }
        }
    }
}

int main() {
    int n;
    std::ios_base::sync_with_stdio(false);
    std::cin >> n;
    int count = 0;
    int sqn = sqrt(n);
    for (int i = 1; i <= sqn; ++i) {
        if ((n % i) == 0) {
            int a1 = i;
            int a2 = n / i;

            LOG("A1:" << a1 << ", A2:" << a2);
            calc(count, a1, n);
            calc(count, a2, n);
        }
    }
    std::cout << count << std::endl;
    return 0;
}