#include <iostream> long long f(long n) { n -= 1; long long result = 0; for (long long i=2;i*i <=n;++i) { if (n%i != 0) continue; if (n/i > 2) ++result; if (i*i == n) continue; if (n/i > 1 && i > 2) ++result; } return result; } int main() { long long n; std::cin >> n; long long result = 0; for (long long i=1; i*i <= n; ++i) { if (n%i != 0) continue; result += f(i); if (i*i == n) continue; result += f(n/i); } std::cout << result << std::endl; 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 | #include <iostream> long long f(long n) { n -= 1; long long result = 0; for (long long i=2;i*i <=n;++i) { if (n%i != 0) continue; if (n/i > 2) ++result; if (i*i == n) continue; if (n/i > 1 && i > 2) ++result; } return result; } int main() { long long n; std::cin >> n; long long result = 0; for (long long i=1; i*i <= n; ++i) { if (n%i != 0) continue; result += f(i); if (i*i == n) continue; result += f(n/i); } std::cout << result << std::endl; return 0; } |