Pagini recente » Autentificare | Istoria paginii planificare/sedinta-20081125 | Cod sursa (job #1772414) | Clasament simulare_oji_ichc_12_03 | Cod sursa (job #189991)
Cod sursa(job #189991)
var phi:array[1..200000] of longint;
f,g:text;
i,n,j,x:longint;
begin
assign(f,'sum.in'); reset(f);
assign(g,'sum.out'); rewrite(g);
n:=200000;
for i:=1 to n do
phi[i]:=i;
for i:=2 to n do
if phi[i]=i then begin
j:=i;
while (j<=n) do begin
phi[j]:=(phi[j] div i)*(i-1);
j:=j+i;
end;
end;
read(f,n);
for i:=1 to n do begin
read(f,x);
if x=1 then
writeln(g,3)
else
writeln(g,x*phi[x] shl 1);
end;
close(f); close(g);
end.