Cod sursa(job #603003)

Utilizator vendetta_galativendetta vendetta_galati Data 14 iulie 2011 01:21:52
Problema Sum Scor 70
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.72 kb
Program suma_info_arena;
var f,g:text;
    a : array[1..100000] of longint;
    n,j,i,q:longint;
begin
     assign(f,'sum.in'); reset(f); readln(f,n);
     assign(g,'sum.out'); rewrite(g); a[1]:=1;
     for i:=1 to 99999 do a[i+1]:=i;
     for i:=2 to 50000 do begin
                          q:=2*i;
                          while q<=100000 do begin
                                             a[q]:=a[q]-a[i];
                                             q:=q+i;
                                             end;
                          end;
     for i:=1 to n do begin
                      readln(f,j);
                      writeln(g,(a[j]*(j shl 1)));
                      end;
     close(f); close(g);
end.