HDU 1556 Color the ball (树状数组-- 区间更新,单点求值)
来源:互联网 发布:pyqt5 eric ubuntu 编辑:程序博客网 时间:2024/05/21 12:40
OJ题目 :点这里~~
与 单点更新,区间求值 稍有不同,需要理解注意。
AC_CODE
int n;int num[100002];int lowbit(int x){ return x&(-x);}int sum(int x){ int ret = 0; while(x > 0) { ret += num[x]; x -= lowbit(x); } return ret;}void add(int x , int d){ while(x <= n) { num[x] += d; x += lowbit(x); }}int main(){ while(scanf("%d",&n)&&n != 0) { int a , b; memset(num , 0 , sizeof(num)); for(int i = 1;i <= n;i++) { scanf("%d%d",&a , &b); add(a , 1);//从a开始的加1 add(b+1 , -1);//从b+1开始的减1 } for(int i = 1;i <= n;i++) { i == n ? printf("%d\n",sum(i)) : printf("%d ",sum(i)); } } return 0;}
0 0
- HDU 1556 Color the ball (树状数组-- 区间更新,单点求值)
- [HDU]1556 Color the ball (树状数组--区间更新,单点求值)
- 【树状数组 区间修改,单点求值】1556 Color the ball
- hdu 1556 Color the ball 【树状数组:区间修改、单点求值】
- HDU - 1556 Color the ball (一维树状数组 + 区间修改 + 单点求值)
- Hdu oj 1556 Color the ball(树状数组区间更新转单点更新)
- HDu 1556 Color the ball【线段树&&树状数组】区间更新,单点查询
- HDU1556 Color the ball 树状数组(区间更新单点求值)
- HDU1556:Color the ball(线段树区间更新单点求值)&&树状数组解法
- Color the ball ---树状数组(区间更新及单点求值)
- HDU 1556 Color the ball【树状数组+区间更新】
- HDU 1556 Color the ball(树状数组区间更新)
- HDU 1556 Color the ball 树状数组-区间更新-模板
- 树状数组:HDU1556 Color the ball 【区间更新,单点查询]
- HDU 1566 Color the ball [树状数组区间更新]【数据结构】
- HDU 1556 Color the ball(树状数组,区间修改,单点统计)
- hdu 1556 Color the ball (树状数组解决区间覆盖+单点查询)
- HDU 1556-Color the ball(树状数组-区间修改 单点查询)
- 如何向外行人解释什么是内存溢出
- dede标签
- 一个公司管理之九:招聘有主见的员工
- Extjs中layout的用法总结
- hdu 神、上帝以及老天爷
- HDU 1556 Color the ball (树状数组-- 区间更新,单点求值)
- JS中的prototype
- 公钥密码标准(PKCS)
- Boost智能指针——shared_ptr
- ARC & NON-ARC混合编译
- windows 下完全删除oracle
- 经典导航栏02,滑动效果,适合做faq或menu
- 网络爬虫系列之二:对下载页面进行链接解析
- 3 种提高编程技能的有趣方法