在写VIJOS P1131时出现这种情况!
program P1131;
var p,q:array[0..500000] of longint;
xo,yo:longint;
i,j,s,sum,yue:longint;
procedure judge(a,b:longint);
var c:longint;
begin
yue:=-1;
if a<b then begin c:=a;a:=b;b:=c; end;
if (a mod b=0) then yue:=b else
begin
c:=a mod b;
judge(b,c);
end;
end;
begin
readln(xo,yo);
repeat
inc(s);
p[s]:=xo*s;q[s]:=xo*s;
until (xo*s>=yo);
for i:=1 to s do
for j:=s downto 1 do
begin
if ((p[i]*q[j]/xo)=yo) then
begin
judge(p[i],q[j]);
if (yue=xo) then
inc(sum);
end;
end;
writeln(sum);
end.
我吧judge写成一个函数 BOOLEAN 然后if ((p[i]*q[j]/xo)=yo) and (judge(p[i],q[j])=xo) then inc(sum);奇怪的是用3 60 做测试时12 和 15却不能让sum+1..为什么??