#include <iostream> #include <vector> using namespace std; typedef long long ll; void D(vector<int>& a, int x) { for (int i = 1; i * i <= x; ++i) { if (x % i == 0) a.push_back(i); if (x % (x / i) == 0 && i != x / i) a.push_back(x / i); } } int main() { ios_base::sync_with_stdio(0); int n; cin >> n; int odp = 0; vector<int> d; D(d, n); for (int i = 0; i < d.size(); ++i) { ll a = d[i]; int n2 = n / a - 1; if (n2 <= 0) continue; vector<int> d2; D(d2, n2); for (int j = 0; j < d2.size(); ++j) { ll b = d2[j]; int n3 = n2 / b - 1; if (n3 <= 0) continue; ll c = n3; if (a < a * b && a * b < a * b * c && a + a * b + a * b * c == n) ++odp; } } cout << odp; 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 | #include <iostream> #include <vector> using namespace std; typedef long long ll; void D(vector<int>& a, int x) { for (int i = 1; i * i <= x; ++i) { if (x % i == 0) a.push_back(i); if (x % (x / i) == 0 && i != x / i) a.push_back(x / i); } } int main() { ios_base::sync_with_stdio(0); int n; cin >> n; int odp = 0; vector<int> d; D(d, n); for (int i = 0; i < d.size(); ++i) { ll a = d[i]; int n2 = n / a - 1; if (n2 <= 0) continue; vector<int> d2; D(d2, n2); for (int j = 0; j < d2.size(); ++j) { ll b = d2[j]; int n3 = n2 / b - 1; if (n3 <= 0) continue; ll c = n3; if (a < a * b && a * b < a * b * c && a + a * b + a * b * c == n) ++odp; } } cout << odp; return 0; } |