1 #include<bits/stdc++.h> 2 using namespace std; 3 //https://www.cnblogs.com/hsd-/p/6139376.html 4 int a[MAXN],tree[MAXN]; 5 //低位一 6 int lowbit(int t) 7 { 8 return t&(-t); 9 } 10 11 //区间更新 12 void update(int x,int y) 13 { 14 while(x<=maxn) 15 { 16 tree[x]+=y; 17 x+=lowbit(x); 18 } 19 20 } 21 22 //区间查询 23 int getsum(int x) 24 { 25 int ans=0; 26 while(x>=1) 27 { 28 ans+=tree[x]; 29 x-=lowbit(x); 30 } 31 return ans; 32 } 33 //更新和查询的为前缀和