代码:
#includeint n,c[100003];int lowbit(int x){ return x&(-x);}int sum(int x){ int sum=0; while(x>0) { sum+=c[x]; x-=lowbit(x); } return sum;}void inster(int x,int i){ while(x<=n) { c[x]+=i; x+=lowbit(x); }}int main(){ int a,b,i; while(scanf("%d",&n)>0&&n) { memset(c,0,sizeof(c)); for(i=0;i