This question is very watery, But WA is a lot better. I want to crash, but I have to pay attention to it. I suddenly found that there are still 0 possibilities. The simple method is enumeration. Set p = a * x; q = B * x; a and B must be of mutual quality, and a * B = y/x, when y % x! = 0 is definitely not possible. Then enumerate the numbers of mutual quality a and B multiplied by 2.
Code:
[Cpp]
# Include <iostream>
# Include <stdio. h>
Using namespace std;
Int GCD (int a, int B)
{
If (B = 0) return;
Return GCD (B, a % B );
}
Int Solve (int n)
{
Int cnt = 1, I;
For (I = 2; I * I <n; I ++ ){
If (n % I! = 0 | n/I % I = 0) continue;
If (GCD (n/I, I) = 1)
Cnt ++;
} Www.2cto.com
Return cnt * 2;
}
Int main ()
{
Int x, y;
While (scanf ("% d", & x, & y )! = EOF ){
If (y % x! = 0) printf ("0 \ n ");
Else if (x = y) printf ("1 \ n ");
Else if (x = 1) printf ("2 \ n ");
Else printf ("% d \ n", Solve (y/x ));
}
Return 0;
}