#include <math.h> #include <stdint.h> #include <iostream> #include <set> std::set<int64_t> divisors(int64_t n) { std::set<int64_t> result; for (int64_t i = 1; i <= sqrt(n); ++i) { if (n % i == 0) { result.insert(i); result.insert(n / i); } } return result; } int main() { int64_t n = 0; std::cin >> n; int64_t count = 0; std::set<int64_t> n_divisors = divisors(n); for (int64_t i : n_divisors) { if (7 * i > n) { break; } std::set<int64_t> ni_divisors = divisors(n / i - 1); ni_divisors.erase(1); for (int64_t a : ni_divisors) { if (3 * a > (n / i) - 1) { break; } count++; } } std::cout << count << 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 34 35 36 37 38 39 40 41 42 43 | #include <math.h> #include <stdint.h> #include <iostream> #include <set> std::set<int64_t> divisors(int64_t n) { std::set<int64_t> result; for (int64_t i = 1; i <= sqrt(n); ++i) { if (n % i == 0) { result.insert(i); result.insert(n / i); } } return result; } int main() { int64_t n = 0; std::cin >> n; int64_t count = 0; std::set<int64_t> n_divisors = divisors(n); for (int64_t i : n_divisors) { if (7 * i > n) { break; } std::set<int64_t> ni_divisors = divisors(n / i - 1); ni_divisors.erase(1); for (int64_t a : ni_divisors) { if (3 * a > (n / i) - 1) { break; } count++; } } std::cout << count << std::endl; return 0; } |