# bzoj3211，bzoj3038

 1 var tree:array[0..400010] of int64;
2     lazy:array[0..400010] of boolean;
3     a:array[0..100010] of int64;
4     n,m,ch,p,q,l,r,i:longint;
5
6 procedure swap(var a,b:longint);
7   var c:longint;
8   begin
9     c:=a;
10     a:=b;
11     b:=c;
12   end;
13
14 procedure update(i:longint);
15   begin
16     tree[i]:=tree[i*2]+tree[i*2+1];
17     lazy[i]:=lazy[i*2] and lazy[i*2+1];
18   end;
19
20 procedure build(i,l,r:longint);
21   var m:longint;
22   begin
23     if l=r then
24     begin
25       tree[i]:=a[l];
26       lazy[i]:=false;
27     end
28     else begin
29       m:=(l+r) shr 1;
30       build(i*2,l,m);
31       build(i*2+1,m+1,r);
32       update(i);
33     end;
34   end;
35
36 procedure work(i,l,r:longint);
37   var m:longint;
38   begin
39     if l=r then
40     begin
41       tree[i]:=trunc(sqrt(tree[i]));
42       if tree[i]=1 then lazy[i]:=true;
43     end
44     else begin
45       m:=(l+r) shr 1;
46       if (p<=m) and not lazy[i*2] then work(i*2,l,m);
47       if (q>m) and not lazy[i*2+1] then work(i*2+1,m+1,r);
48       update(i);
49     end;
50   end;
51
53   var m:longint;
54   begin
55     if (p<=l) and (q>=r) then exit(tree[i])
56     else begin
57       m:=(l+r) shr 1;
61     end;
62   end;
63
64 begin
66   for i:=1 to n do
68   build(1,1,n);
70   for i:=1 to m do
71   begin
79 end.