一维
#include<cstdio>
#include<iostream>
#define N 10000
using namespace std;
int n,a[N],c[N];
int lowbit(int x){
return x&(-x);
}
void modify(int k,int d){
int t=k;
while (t<=n){
c[t]+=d;
t+=lowbit(t);
}
}
int query(int k){
int ans=0,t=k;
while (t){
ans+=c[t];
t-=lowbit(t);
}
return ans;
}
int main(){
cin >> n;
for (int i=1;i<=n;i++) scanf("%d",&a[i]);
return 0;
}
二维
#include<cstdio>
#include<iostream>
#define N 10000
using namespace std;
int n,a[N][N],c[N][N];
int lowbit(int x){
return x&(-x);
}
void modify(int k,int l,int d){
int x=k,y;
while (x<=n)
{
y=l;
while (y<=n)
{
c[x][y]+=d;
y+=lowbit(y);
}
x+=lowbit(x);
}
}
int query(int k,int l){
int ans=0,x=k,y;
while(x)
{
y=l;
while(y)
{
ans+=c[x][y];
y-=lowbit(y);
}
x-=lowbit(x);
}
return ans;
}
int main(){
cin >> n;
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++) scanf("%d",&a[i][j]);
return 0;
}