Title Description
Description
Enter two positive integer x0,y0 (2<=x0<100000,2<=y0<=1000000) to find the number of p,q that meet the following conditions
Condition: 1.p,q is a positive integer
2. Require p,q to x0 for greatest common divisor, y0 as least common multiple.
Trial: The number of all possible two positive integers that satisfy the condition.
Enter a description
Input Description
Two positive integers x0,y0
Output description
Output Description
The number of all possible two positive integers that satisfy the condition
Sample input
Sample Input
3 60
Sample output
Sample Output
4
Data range and Tips
Data Size & Hint
Exercises
Number theory + enumeration.
Equation 1: Two numbers of least common multiple * greatest common divisor = two numbers of product.
Equation 2: Greatest common divisor gcd (A, B) =gcd (b,a%b).
var X,y,j,k,ans:int64;
I:longint;
function gcd (X,y:int64): Int64;
Begin
If Y=0 then exit (x)
else exit (gcd (y,x mod y));
End
Begin
READLN (x, y);
For I:=x to Y do
Begin
J:=x*y Div i;
K:=GCD (I,J);
if (k=x) and (i*j Div k=y) then Inc (ANS);
End
Write (ANS);
End.
2001 Greatest common divisor and the minimum number of conventions