|
|
вернуться в форумWhy my program work so long??? Послано S7 18 июл 2003 01:45 This is my solve. Judge write Time Limit Ex.. But on my PC program very fast.. Why??/? { @JUDGE_ID: 22797EM 1086 Pascal } program Cryptography_1086; const max=15000; type int=1..max; mas_find=array [int] of longint; var limit:integer; k,i,j,kolvo,n:int; simple:boolean; candidat:longint; Find:mas_find; BEGIN readln(k); for i:=1 to k do begin readln(n); if n=1 then begin writeln(2); continue; end; candidat:=3; find[1]:=2; kolvo:=1; while kolvo<n do begin limit:=trunc(sqrt(candidat)); simple:=true; for j:=1 to kolvo do begin if j=1 then continue; if Find[j]>limit then break; if candidat mod find[j]=0 then begin simple:=false; break; end; end; if simple then begin inc(kolvo); find[kolvo]:=candidat; end; inc(candidat,2); end; writeln(Find[kolvo]); end; END. Re: Why my program work so long??? Use Eratosfen Grid |
|
|