Cod sursa(job #16041)

Utilizator adalLica Adela adal Data 11 februarie 2007 23:13:28
Problema Sum Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.76 kb
program sum;
var
procedure ciur(max:longint);
var i,j:longint;
begin
  i:=1;
  while ((i*i) shl1)+(i shl 1)<=max do begin
     if (v[i shr3]shr(i and 7)) and 1=0 then begin
         j:=((i*i) shl 1)+(i shl 1);
         while (2*j+1) <=max do begin
             v[j shr 3]:=v[j shr 3] or(1 shr(j and 7));
             j:=j +(i shl 1) +1;
         end;
      end;
     inc(i);
  end;
  b[0]:=1; b[1]:=2;
  for i:=1 to max do
    if (v[i shr 3] shr(i and 7)) and 1=0 then
       if (2*i+1<=n) then begin inc(b[0]);  b[b[0]]:=2*i+1; end;
end;
begin
  assign(f,'sum.in'); reset(f);
  assign(g,'sum.out'); rewrite(g);
  readln(f,n);
  for i:=1 to n do begin
     readln(f,a[i])
     if a[i]>max then max:=a[i];
  end;
  ciur(max);
  for i:=1 to n do begin