輸入二個正整數x0,y0(2<=x0<100000,2<=y0<=1000000),求出滿足下列條件的P,Q的個數
條件: 1.P,Q是正整數
2.要求P,Q以x0爲最大公約數,以y0爲最小公倍數.
試求:滿足條件的所有可能的兩個正整數的個數.
代碼:
var
x,y,sum,temp,tot,t,z:longint;function gcd(a,b:longint):longint;
var
c:longint;
begin
repeat
c:=a mod b;
a:=b;
b:=c;
until c=0;
gcd:=a;
end;
begin
readln(x,y);
sum:=x*y;
for temp:=x to y do
begin
tot:=sum div temp;
z:=gcd(temp,tot);
if z=x then
if temp*tot div z=y then
inc(t);
end;
writeln(t);
end.