#3709: PASCAL——TLE


annieicaros (annie_fei)


var
a,b,x:longint;
begin
while not seekeof do begin
 x:=0;
 readln(a);
 for b:=2 to a-1 do
 begin
 if a mod b=0 then x:=1;
 end;
if a<=1 then x:=1;
case x of
0:writeln('質數');
1:writeln('非質數');
end;
end;
end.

----------

以上用了大量mod,可能超時

有什麽簡便方法?

#3710: Re:PASCAL——TLE


magrady (元元)


var
a,b,x:longint;
begin
while not seekeof do begin
 x:=0;
 readln(a);
 for b:=2 to a-1 do
 begin
 if a mod b=0 then x:=1;
 end;
if a<=1 then x:=1;
case x of
0:writeln('質數');
1:writeln('非質數');
end;
end;
end.

----------

以上用了大量mod,可能超時

有什麽簡便方法?


不是Pascal的問題。