just write the right ...
The title is so long, it is actually 2 operations:
1. Inquire about the sum of each number in the L,r
2. Place each number x in the L,r x, Fix the X1/2, take the whole down.
We can actually find that the number in 1000000000 doesn't change a few times, it turns into 1.
Then the direct violence changes, if a period of the number of all <=1 will not have to change.
#include <stdio.h>#include<iostream>#include<algorithm>#include<math.h>using namespacestd;#defineP1 (p<<1)#defineP2 (p<<1|1)Const intn=100005;intn,m,i,p,x,y,a[n],add[n<<2];Long Longans,t[n<<2];voidBuildintLintRintp) { if(l==R) {T[p]=A[l]; if(a[l]<=1) add[p]=1;Elseadd[p]=0; return; } intMid= (l+r) >>1; Build (L,MID,P1); Build (Mid+1, R,P2); T[P]=t[p1]+T[P2]; ADD[P]=add[p1]&ADD[P2];}voidUpdateintLintRintXintYintp) { if(Add[p])return; if(l==R) {T[p]=(int) (sqrt (t[p])); if(t[p]<=1) add[p]=1; return; } intMid= (l+r) >>1; if(x<=mid) Update (L,MID,X,Y,P1); if(y>mid) Update (mid+1, R,X,Y,P2); ADD[P]=add[p1]&ADD[P2]; T[P]=t[p1]+T[P2];}voidSolveintLintRintXintYintp) { if(x<=l&&r<=y) {ans+=T[p]; return; } intMid= (l+r) >>1; if(x<=mid) solve (L,MID,X,Y,P1); if(Y>mid) Solve (mid+1, R,X,Y,P2);}intMain () {scanf ("%d",&N); for(i=1; i<=n;i++) scanf ("%d",&A[i]); Build (1N1); scanf ("%d",&m); for(i=1; i<=m;i++) {scanf ("%d%d%d",&p,&x,&y); if(p==1) {ans=0; Solve (1, N,x,y,1); printf ("%lld\n", ans); } ElseUpdate (1, N,x,y,1); } return 0;}
3211: The flower God travels the country