Pagini recente » Cod sursa (job #2017005) | Cod sursa (job #171937) | Cod sursa (job #1517844) | Clasament dupa rating | 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.