水题,已经最大公约数和最小公倍数,求两个数可能的组合数
#include<cstdio>
using namespace std;
namespace
{
int gcd(int a, int b)
{
if (!a)
return b;
return gcd(b % a, a);
}
}
int main()
{
int x, y;
while (scanf("%d %d", &x, &y) != EOF)
{
if (y % x)
puts("0");
else if (x == y)
puts("1");
else
{
int res = 1, num = y / x;
for (int i = 2; i * i <= num; i++)
if (num % i == 0 && gcd(i, num / i) == 1)
res++;
printf("%d\n", res << 1);
}
}
return 0;
}