#include <iostream> using namespace std; int solve_c(int b, int na) { if (b < 2) return 0; if (na / b - 1 > 1) return 1; return 0; } int solve_b(int a, int n) { int cnt = 0; int na = n / a - 1; if (na < 2) return 0; for (int i = 1; i * i <= na; ++i) { if (na % i == 0) { cnt += solve_c(i, na); if (na / i != i) cnt += solve_c(na / i, na); } } return cnt; } int solve_a(int n) { int cnt = 0; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { cnt += solve_b(i, n); if (n / i != i) cnt += solve_b(n / i, n); } } return cnt; } int main() { int n; cin >> n; cout << solve_a(n); 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 | #include <iostream> using namespace std; int solve_c(int b, int na) { if (b < 2) return 0; if (na / b - 1 > 1) return 1; return 0; } int solve_b(int a, int n) { int cnt = 0; int na = n / a - 1; if (na < 2) return 0; for (int i = 1; i * i <= na; ++i) { if (na % i == 0) { cnt += solve_c(i, na); if (na / i != i) cnt += solve_c(na / i, na); } } return cnt; } int solve_a(int n) { int cnt = 0; for (int i = 1; i * i <= n; ++i) { if (n % i == 0) { cnt += solve_b(i, n); if (n / i != i) cnt += solve_b(n / i, n); } } return cnt; } int main() { int n; cin >> n; cout << solve_a(n); return 0; } |