Pagini recente » Cod sursa (job #2721171) | Cod sursa (job #38167) | Cod sursa (job #2768271) | Cod sursa (job #2192372) | Cod sursa (job #136433)
Cod sursa(job #136433)
var n,i,k,ct,h:longint;
p:array[1..10000] of longint;
f,g:text;
begin
assign(f,'prim.in'); reset(f);
readln(f,k);
close(f);
i:=2; ct:=1; h:=4; n:=10*k;
while (h<n) do begin
p[h]:=1; h:=h+i;
end;
i:=3;
while ct<=k do begin
h:=i;
if p[i]=0 then begin inc(ct);
h:=h+2*i;
while h<=n do begin
p[h]:=1;
h:=h+2*i;
end;
end;
i:=i+2;
end;
assign(g,'prim.out'); rewrite(g);
if k>1 then
write(g,(i-2)*(i-2))
else write(g,'9');
close(g);
end.