您当前的位置: 首页 > 

不牌不改

暂无认证

  • 7浏览

    0关注

    422博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

树状数组

不牌不改 发布时间:2020-08-21 21:49:20 ,浏览量:7

先附上链接,https://www.cnblogs.com/findview/p/11281628.html 写的是真的言简意赅,平易近小白,强推。

树状数组板子
//板子
#include
using namespace std;
int n;
int a[1000],c[1000];
int lowbit(int x){
 	return x&(-x);
}
int getsum(int x){
 	int ans=0;
 	while(x>0){
  		ans+=c[x];
  		x-=lowbit(x);//-,注意
 	}
 	return ans;
}
void update(int x,int add){
 	a[x]+=add;//注意
 	while(x>n;
 	for(int i=1;i>tmp;
  		update(i,tmp);//输入的过程就是更新的过程 
 	}
 	int ans=getsum(n-1);
 	cout            
关注
打赏
1662186765
查看更多评论
0.0416s