#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int n, result = 0; cin >> n; for (int a = 1; a <= sqrt(n); a++) { if (n%a != 0) continue; int k = n / a - 1; for (int j = 2; j <= sqrt(k); j++) { if (k%j != 0) continue; else if (j == 2 && k / j == 2) result += 0; else if (j == 2 || k / j == 2 || j == k / j) result += 1; else result += 2; } if (a == n / a) continue; k = a - 1; for (int j = 2; j <= sqrt(k); j++) { if (k%j != 0) continue; else if (j == 2 && k / j == 2) result += 0; else if (j == 2 || k / j == 2 || j == k / j) result += 1; else result += 2; } } cout << result << 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 39 40 41 42 43 44 | #include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int n, result = 0; cin >> n; for (int a = 1; a <= sqrt(n); a++) { if (n%a != 0) continue; int k = n / a - 1; for (int j = 2; j <= sqrt(k); j++) { if (k%j != 0) continue; else if (j == 2 && k / j == 2) result += 0; else if (j == 2 || k / j == 2 || j == k / j) result += 1; else result += 2; } if (a == n / a) continue; k = a - 1; for (int j = 2; j <= sqrt(k); j++) { if (k%j != 0) continue; else if (j == 2 && k / j == 2) result += 0; else if (j == 2 || k / j == 2 || j == k / j) result += 1; else result += 2; } } cout << result << endl; } |