#include <iostream> #include <vector> using namespace std; vector<int> divisors(int n) { vector<int> r; for (int i=1; i*i <= n; i ++) { if (n % i == 0) { r.push_back(i); if (n / i != i) r.push_back(n / i); } } return r; } int main() { int n; cin >> n; int res = 0; for (int a : divisors(n)) { int r = n / a - 1; if (r <= 1) continue; for (int k : divisors(r)) { if (k == 1) continue; int m = r / k - 1; if (m == 0 || m == 1) continue; res ++; //cout << a << " " << a * k << " " << a * k * m << endl; } } cout << res << endl; }
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 | #include <iostream> #include <vector> using namespace std; vector<int> divisors(int n) { vector<int> r; for (int i=1; i*i <= n; i ++) { if (n % i == 0) { r.push_back(i); if (n / i != i) r.push_back(n / i); } } return r; } int main() { int n; cin >> n; int res = 0; for (int a : divisors(n)) { int r = n / a - 1; if (r <= 1) continue; for (int k : divisors(r)) { if (k == 1) continue; int m = r / k - 1; if (m == 0 || m == 1) continue; res ++; //cout << a << " " << a * k << " " << a * k * m << endl; } } cout << res << endl; } |