Pagini recente » Cod sursa (job #2406550) | Cod sursa (job #1683104) | Cod sursa (job #1587320) | Cod sursa (job #1644899) | Cod sursa (job #189993)
Cod sursa(job #189993)
var phi:array[1..200000] of longint;
f,g:text;
i,n,j:longint;
q,x:qword;
begin
assign(f,'sum.in'); reset(f);
assign(g,'sum.out'); rewrite(g);
n:=200000;
for i:=2 to n do
phi[i]:=i;
j:=2;
while (j<=n) do begin
phi[j]:=phi[j] shr 1;
j:=j+2;
end;
for i:=3 to n do
if phi[i]=i then begin
j:=i;
while (j<=n) do begin
phi[j]:=phi[j]-(phi[j] div i);
j:=j+i;
end;
end;
phi[1]:=0;
read(f,n);
for i:=1 to n do begin
read(f,x);
q:=(x*phi[x]) shl 1;
writeln(g,x*phi[x] shl 1);
end;
close(f); close(g);
end.