HDU1556 树状数组
来源:互联网 发布:淘宝网店转让价格 编辑:程序博客网 时间:2024/05/30 04:14
点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1556
蓝桥杯时看到树状数组,于是就学习了下,没什么好解释的
/* ***********************************************Author :小蔡虎Created Time :2016/File Name :E:\2016ACM\HDU状态 :************************************************ */#include<stdio.h>#include<string.h>#include<string>#include<algorithm>#include<math.h>#include<iostream>#include<time.h>#define PI 3.141592654#define MA 100010using namespace std;/**/int tr[MA],n;int getsum(int x){ int sum=0; while(x<=n) { sum+=tr[x]; x+=x&(-x); } return sum;}void updata(int x,int mun){ while(x>0) { tr[x]+=mun; x-=x&(-x); }}int main(){ int a,b,i; while(scanf("%d",&n),n) { memset(tr,0,sizeof(tr)); for(i=0;i<n;i++) { scanf("%d%d",&a,&b); updata(a-1,-1); updata(b,1); } for(i=1;i<n;i++) { printf("%d ",getsum(i)); } printf("%d",getsum(n)); printf("\n"); } return 0;}
0 0
- hdu1556树状数组
- hdu1556--树状数组
- HDU1556 树状数组
- hdu1556 树状数组
- hdu1556(树状数组)
- 树状数组专题(六)hdu1556
- hdu1556 简单的树状数组
- hdu1556树状数组更新区间
- HDU1556 树状数组 高级应用
- hdu1556 Color the ball (树状数组)
- poj2352&&hdu1556&&poj2481(树状数组)
- HDU1556 Color the ball (树状数组)
- hdu1556(树状数组)(单点求值)
- hdu1556 树状数组 区间修改,点查询
- [树状数组]HDU1556 Color the ball
- hdu1556 Color the ball(树状数组)
- Hdu1556 Color the ball [分块][树状数组]
- [HDU1556] Color the ball - 树状数组
- c++上机作业1
- 梯度下降法(Gradient descent)
- hadoop伪分布式搭建
- 网络地址划分标准
- Deep learning:三十六(关于构建深度卷积SAE网络的一点困惑)
- HDU1556 树状数组
- 谈谈对struts2,hibernate,spring的理解
- Java HashMap&Hashtable 源代码分析
- java 动态代理
- Deep learning:三十七(Deep learning中的优化方法)
- 捕获效应1:有线网络中的捕获效应
- 【模板】dinic(网络流)
- 杭电2084数塔
- Deep learning:三十八(Stacked CNN简单介绍)