#include<iostream> #include<string> using namespace std; long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a%b); } int main() { long x, y; while (cin >> x >> y) { int sum = 0; for (long i = x; i <= y/2; i += x) { double d = x*1.0 * y / i; if (gcd(i, d) == x && d - int(d) == 0) //cout << i <<' '<< d << endl; sum++; } cout << sum*2 << endl; } } |
Double click to view unformatted code.