hdu 1556
来源:互联网 发布:java接口开发 编辑:程序博客网 时间:2024/04/29 09:33
http://blog.csdn.net/geniusluzh/article/details/5900453
#include<iostream>
using namespace std;int tree[100100];
int maxn;
void update(int k,int v)
{
while(k<=maxn)
{
tree[k]+=v;
k+=k&-k;
}
}
int read(int k)//求区间1到k的和值
{
int sum=0;
while(k>0)
{
sum+=tree[k];
k-=k&-k;
}
return sum;
}
int main()
{
int i,a,b,temp;
while(scanf("%d",&maxn)&&maxn)
{
temp=maxn;
memset(tree,0,sizeof(tree));
while(temp--)
{
scanf("%d%d",&a,&b);
update(a,1);
update(b+1,-1);
}
for(i=1;i<=maxn;i++)
{
printf("%d",read(i));
if(i!=maxn)
printf(" ");
else
printf("/n");
}
}
return 0;
}
- hdu 1556
- hdu 1556
- HDU 1556
- hdu 1556
- hdu 1556
- hdu 1556
- hdu 1556
- (1556)HDU
- hdu 1556
- hdu 1556
- HDU 1556
- HDU 1556
- hdu--1556
- hdu 1556
- hdu 1556
- hdu:1556
- HDU 1556
- HDU 1556
- cocos2d_字体
- Linux Shell脚本编程--Head/Tail命令详解
- android中自定义view构造函数ContentItemView(Context context, AttributeSet paramAttributeSet)的用处
- iOS应用性能调优的25个建议和技巧
- linux中Find命令的使用
- hdu 1556
- UVA 10026 Shoemaker's Problem 鞋匠的难题 贪心+排序
- _tcschrs,_tcslen,WideCharToMultiByte,MultiByteToWideChar,mbstowcs,wcstombs字符串操作
- POJ 1045
- 广度优先搜索
- ARM中的MOV指令
- UIView你知道多少
- CentOS 6.x 配置yum源
- java加密枝术