标签:
1 void ins(int k,int x,int t){ 2 for (; x<=tot; x+=x&-x) c[k][x]+=t; 3 } 4 ll getsum(int k,int x){ 5 ll t=0; for (; x; x-=x&-x) t+=c[k][x]; return t; 6 } 7 void mdy(int x,int y,int z){ 8 ins(0,x,z); ins(1,x,z*(x-1)); ins(0,y+1,-z); ins(1,y+1,-z*y); 9 } 10 ll qry(int x,int y){ 11 return getsum(0,y)*y-getsum(1,y)-getsum(0,x-1)*(x-1)+getsum(1,x-1); 12 }
标签:
原文地址:http://www.cnblogs.com/Kurokey/p/5628450.html