Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- size_t factorize(long long x) {
- std::vector<long long> factors;
- for (long long i = 2; i <= std::sqrt((long double) x); i++) {
- if (x % i == 0) {
- factors.emplace_back(i);
- }
- while (x % i == 0) {
- x /= i;
- }
- }
- if (x != 1) {
- factors.emplace_back(x);
- }
- return std::pow(2, factors.size()) ;
- }
- int main() {
- long long a, b;
- std::cin >> a >> b;
- if (a == b) {
- std::cout << 1 << '\n';
- exit(EXIT_SUCCESS);
- }
- if (a < b) {
- std::swap(a, b);
- }
- if (a % b != 0) {
- std::cout << 0 << '\n';
- exit(EXIT_SUCCESS);
- }
- long long to_check = a / b;
- auto res = factorize(to_check);
- std::cout << res << '\n';
- return 0;
- }
Add Comment
Please, Sign In to add comment