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

Discussion of Problem 1086. Cryptography

Pls help!!!
Posted by Ivan Brigida 15 Aug 2002 13:46
Why the result of testing is WA?
Here is my program:
 const max=15000;
 var
  a:array[1..max] of longint;
  k:integer;
  f:text;
  procedure readdata;
   var i,m:integer;
   begin
    assign(f,'temp.tmp');
    rewrite(f);
    readln(k);
    for i:=1 to k do begin
     readln(m);
     writeln(f,a[m]);
    end;
    close(f);
   end;{p..readdata}
  function ifp(n:longint):boolean;
   var k:longint;
   begin
     ifp:=false;
     k:=2;
     while (n mod k<>0) and (k*k<n) do k:=k+1;
     if k*k>n then ifp:=true;
   end;
  procedure makep;
   var k:integer;
       p:longint;
   begin
    k:=1;
    p:=2;
    while k<=max do
     if ifp(p) then begin
      a[k]:=p;
      k:=k+1;
      p:=p+1;
     end
     else p:=p+1;
  end;{p.. makep}
 procedure print;
  var i:integer;
      k:longint;
  begin
   reset(f);
   for i:=1 to k do begin
    readln(f,k);
    writeln(k);
   end;
   close(f);
   erase(f);
  end; {p..print}
begin
 makep;
 readdata;
 print;
end.