ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Where is wrong-1086
Posted by Shteyner Sergey 24 Apr 2003 09:30
var i, k, j, s, n, l:longint;
bool:boolean;
a:array [1..1000] of integer;
p:array [1..15000] of longint;
begin
  Read (n);
  for i:= 1 to n do Readln (a [i]);
  s:=1;
  for i:= 2 to n do if a [s] < a [i] then s:=i;
  i:=3;  k:=1; p [1]:=2;
  if a [s] <> 1 then
    repeat
      bool:=true;
      for j:=1 to (trunc (sqrt (i)) div 2) do
       if (i mod (2*j+1)) = 0 then
        begin
         bool:=false;
         break;
        end;
      if bool then
       begin
        inc (k);
        p [k]:=i;
       end;
       inc (i, 2);
    until (k=a [s]);
    for i:= 1 to n do write (p [a [i]], ' ');
end.