#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define PB push_back
typedef unsigned long long ULL;
typedef vector<ULL> VLL;
#define DEBUG false
VLL dzielniki(ULL n) {
VLL pom, res;
for (ULL i = 1; i * i <= n; i++) {
if (n % i == 0) {
res.PB(i);
if (i * i != n) {
pom.PB(n / i);
}
}
}
reverse(pom.begin(), pom.end());
for (auto x : pom) {
res.PB(x);
}
return res;
}
int main() {
ULL n, a, b, c;
scanf("%lld", &n);
VLL dn = dzielniki(n);
if (DEBUG) {
for (auto x : dzielniki(64)) {
printf("%lld ", x);
}
printf("\n");
for (auto x : dzielniki(63)) {
printf("%lld ", x);
}
printf("\n");
}
int wynik = 0;
for (auto a : dn) {
if (a * 7 <= n) {
VLL dmb = dzielniki((n - a) / a);
for (auto mb : dmb) {
b = a * mb;
if (b >= a * 2 && b * 3 <= n - a) {
wynik++;
if (DEBUG) {
printf("(%lld, %lld, %lld)\n", a, b, (n - a - b));
}
}
}
}
}
printf("%d\n", wynik);
return 0;
}
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include <iostream> #include <cstdio> #include <vector> #include <algorithm> using namespace std; #define PB push_back typedef unsigned long long ULL; typedef vector<ULL> VLL; #define DEBUG false VLL dzielniki(ULL n) { VLL pom, res; for (ULL i = 1; i * i <= n; i++) { if (n % i == 0) { res.PB(i); if (i * i != n) { pom.PB(n / i); } } } reverse(pom.begin(), pom.end()); for (auto x : pom) { res.PB(x); } return res; } int main() { ULL n, a, b, c; scanf("%lld", &n); VLL dn = dzielniki(n); if (DEBUG) { for (auto x : dzielniki(64)) { printf("%lld ", x); } printf("\n"); for (auto x : dzielniki(63)) { printf("%lld ", x); } printf("\n"); } int wynik = 0; for (auto a : dn) { if (a * 7 <= n) { VLL dmb = dzielniki((n - a) / a); for (auto mb : dmb) { b = a * mb; if (b >= a * 2 && b * 3 <= n - a) { wynik++; if (DEBUG) { printf("(%lld, %lld, %lld)\n", a, b, (n - a - b)); } } } } } printf("%d\n", wynik); return 0; } |
English