http://www.lydsy.com/JudgeOnline/problem.php?id=3038
http://www.lydsy.com/JudgeOnline/problem.php?id=3211
给一个序列,支持两种操作
1.对[L,R]内的数求和
2.对[L,R]内的每一个a[i]变为sqrt(a[i])
var
w:array[0..600000,1..4]of int64;
x:array[0..100000]of int64;
i,j,k:longint;
n,m:longint;
a,b,c,d:longint;
procedure build(a,l,r:longint);
var mid:longint;
begin
w[a,1]:=l; w[a,2]:=r;
if l=r
then begin
w[a,3]:=x[l];
if x[l]<=1
then w[a,4]:=1 else w[a,4]:=0;
exit;
end;
mid:=(l+r)>>1;
build(a*2,l,mid); build(a*2+1,mid+1,r);
w[a,3]:=w[a*2,3]+w[a*2+1,3];
if (w[a*2,4]=1)and(w[a*2+1,4]=1)
then w[a,4]:=1 else w[a,4]:=0;
end;
procedure update(a,l,r:longint);
var mid:longint;
begin
if w[a,4]=1 then exit;
if w[a,1]=w[a,2]
then begin
w[a,3]:=trunc(sqrt(w[a,3]));
if w[a,3]<=1
then w[a,4]:=1 else w[a,4]:=0;
exit;
end;
mid:=(w[a,1]+w[a,2])>>1;
if r<=mid then update(a*2,l,r) else
if l>mid then update(a*2+1,l,r)
else begin update(a*2,l,mid); update(a*2+1,mid+1,r) end;
w[a,3]:=w[a*2,3]+w[a*2+1,3];
if (w[a*2,4]=1)and(w[a*2+1,4]=1)
then w[a,4]:=1 else w[a,4]:=0;
end;
function query(a,l,r:longint):int64;
var mid:longint;
begin
if (w[a,1]=l)and(w[a,2]=r) then exit(w[a,3]);
mid:=(w[a,1]+w[a,2])>>1;
if r<=mid then exit(query(a*2,l,r)) else
if l>mid then exit(query(a*2+1,l,r))
else exit(query(a*2,l,mid)+query(a*2+1,mid+1,r));
end;
begin
readln(n);
for i:=1 to n do
read(x[i]);
build(1,1,n);
readln(m);
for i:=1 to m do
begin
readln(a,b,c);
if b>c
then begin d:=b; b:=c; c:=d; end;
case a of
1:begin writeln(query(1,b,c)); end;
0:begin update(1,b,c); end;
end;
end;
end.