Created
October 18, 2019 04:03
-
-
Save chenminhua/d10ac7347ce531c2688f0cf21b5e4ed5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a[maxn]; | |
int lowbit(int x) | |
{ | |
return x&(-x); | |
} | |
void add(int x,int y) | |
{ | |
while(x<=n) | |
{ | |
a[x]+=y; | |
x+=lowbit(x); | |
} | |
} | |
int sum(int x) | |
{ | |
int s=0; | |
while(x>0) | |
{ | |
s+=a[x]; | |
x-=lowbit(x); | |
} | |
return s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment