Given x and y (2 <= x <= 100,000, 2 <= y <= 1,000,000), you are to count the number of p and q such that:
1) p and q are positive integers;
2) GCD(p, q) = x;
3) LCM(p, q) = y.
input
There are multiple test cases, each case contains two integers x and y, one line for each test case.
output'Number of pairs of p and q.
sample input
3 60
sample output
4
题目大意:就是找出p*q=x*y,pq的对数。
用一个公式很好:(a/gcd )*(b/gcd)= lcm/gcd(其实是百度的)
这样子把lcm的数量级降下来了。
而且左边2块互质,这样子递归求解最大公约数时的层次走少了好几步。不容易超时,一开始超时到绝望。