码迷,mamicode.com
首页 > 其他好文 > 详细

树状数组小模板......

时间:2014-08-22 17:56:29      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:acm   暑期集训   算法   

(1)“改点求段”型

树状数组模板题—hdu1166+poj2352 - Delacour_的专栏 - 博客频道 - CSDN.NET

http://blog.csdn.net/delacour_/article/details/33364033

树状数组区间求和三种模型 - mr_lee - 博客频道 - CSDN.NET
http://blog.csdn.net/q573290534/article/details/6664454


int lowbit(int a)  

{  
    return a&(-a);
}  
void init()  
{  
    for (int i=1;i<=n;i++)
bit[i]=0;
}  
void updata(int x,int add)  
{  
    while(x<=n)
{
bit[x]+=add;
   x+=lowbit(x);
printf("%d",x);


    }printf("%d\n");


}  
int sum(int a)  
{   int ans=0;
    while(a>0)
{

ans+=bit[a];
   a-=lowbit(a);
   printf("%d",a);
    }
return ans;
}  

树状数组小模板......

标签:acm   暑期集训   算法   

原文地址:http://blog.csdn.net/a599677743/article/details/38733507

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!