Cod sursa(job #810440)

Utilizator t.g.g.tt.g.g.t t.g.g.t Data 10 noiembrie 2012 12:41:47
Problema Sum Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.93 kb
const max=100000;
var b:array[1..100000]of longint; a:array[1..100000]of byte; sf,t:int64;  i,j,n,nr,pr,t1:longint; buf1,buf2:array[1..1 shl 16]of char;
begin
for i:=2 to 500 do begin if a[i]=0 then begin j:=i*i; while j<=max do begin a[j]:=1; j:=j+i; end end; end;
a[2]:=1;
for i:=2 to max do begin
                     if b[i]=0 then b[i]:=i-1;
                     if i<(max div 2)+1 then begin j:=2*i;
                     while j<=max do begin
                                        if b[j]=0 then b[j]:=j-1-b[i]
                                                  else b[j]:=b[j]-b[i];
                                        j:=j+i
                                   end; end;
                 end;
assign(input,'sum.in'); reset(input); settextbuf(input,buf1);
assign(output,'sum.out'); rewrite(output); settextbuf(output,buf2);
readln(n);
for i:=1 to n do
  begin
    readln(t);
    sf:=b[t]*2*t;
    writeln(sf);
  end;
close(output);
end.