#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+;
int n;
int c[maxn];
int lowbit(int x) { return x&(-x); }
void update(int num,int val)
{
while(num)
{
c[num]+=val;
num-=lowbit(num);
}
}
int getsum(int num)
{
int sum=;
while(num<=n)
{
sum+=c[num];
num+=lowbit(num);
}
return sum;
}
int32_t main()
{
while()
{
cin>>n;
if(n==) break;
memset(c,,sizeof(c));
for(int i=;i<=n;i++)
{
int a,b; cin>>a>>b;
update(b,);
update(a-,-);
}
for(int i=;i<=n;i++)
{
cout<<getsum(i);
if(i!=n) cout<<" ";
}cout<<endl;
}
}

hdu 1556 树状数组

hdu 1556 A - Color the ball 数状数组做法的更多相关文章

  1. HDOJ/HDU 1556 Color the ball(树状数组)

    Problem Description N个气球排成一排,从左到右依次编号为1,2,3-.N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动车从 ...

  2. HDU 1556 Color the ball (树状数组区间更新)

    水题,练习一下树状数组实现区间更新. 对于每个区间,区间左端点+1,右端点的后一位-1,查询每个位置的覆盖次数 #include <cstdio> #include <cstring ...

  3. Color the ball(树状数组+线段树+二分)

    Color the ball Time Limit : 9000/3000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  4. HDU 1556 Color the ball 树状数组 题解

    Problem Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动 ...

  5. hdu 1556 A - Color the ball 其他做法

    #include<bits/stdc++.h> using namespace std; ; int c[maxn]; int n; int main() { ) { cin>> ...

  6. HDU 1166 敌兵布阵 (数状数组,或线段树)

    题意:... 析:可以直接用数状数组进行模拟,也可以用线段树. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000&quo ...

  7. hdu 5869 区间不同GCD个数(树状数组)

    Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  8. poj 2481 Cows(数状数组 或 线段树)

    题意:对于两个区间,[si,ei] 和 [sj,ej],若 si <= sj and ei >= ej and ei - si > ej - sj 则说明区间 [si,ei] 比 [ ...

  9. hdu 6203 ping ping ping(LCA+树状数组)

    hdu 6203 ping ping ping(LCA+树状数组) 题意:给一棵树,有m条路径,问至少删除多少个点使得这些路径都不连通 \(1 <= n <= 1e4\) \(1 < ...

随机推荐

  1. learning rndis protocol

    reference:  https://docs.microsoft.com/en-us/windows-hardware/drivers/network/overview-of-remote-ndi ...

  2. java中super关键字的用法

    class Sum { int n; float f() { float sum=0; for(int i=1;i<=n;i++) sum=sum+i; System.out.println(& ...

  3. win10与centos7的双系统U盘安装(二:安装以及配置centos系统)

    继续第一篇的讲解,接着就是要进入第二部分——安装以及配置centos系统 特别提醒在安装centos之间,注意自己的win10系统进行备份,便于回复安装失败后的系统 1:安装前准备 安装前准备主要是两 ...

  4. hdu3518

    题解: 后缀数组 枚举长度为k(1<=k<=len/2)的满足要求的子串个数 代码: #include<cstdio> #include<cmath> #inclu ...

  5. word个人信息的一种处理方式

    下面是一种解决office文件更改作者的方法,步骤如下: 第一步:进入Word,Excel,或PowerPoint, 随便打开一个文件: 第二步:点击左上角的文件,进入文件功能界面: 第三步:点击选项 ...

  6. IDE 版本

    BDS 5 2007 D11  VER180 and VER185 RAD Studio 8 XE D15  VER 220 RAD 18 XE 10.1 Berlin D24  VER310  St ...

  7. el表达式原样输出,不被解析

    今天遇到了,在jar包都有的前提下EL表达式原样输出,不被解析,原因是: page指令中确少 isELIgnored="false" 加上就好了 <%@ page langu ...

  8. 团队项目开发特点以及NABCD分析总结

    (注:此博客来源于韩晓凡,我们是一个团队) 团队项目的特点:开发的这款软件是从我们的日常生活中得到的启发,现在正是大学阶段,刚刚开始管理自己每个月的生活费,并且在大学中每个月的生活费会有很多去处,然而 ...

  9. JavaWeb基础-认识JavaWeb

    程序开发体系 B/S 浏览器/服务器 开发维护成本低 客户端负载低 安全性低 C/S 客户端/服务器 成本高 客户端负载高 安全性高 javaweb简介 静态网页 HTML CSS,人浏览的数据是始终 ...

  10. php优秀框架codeigniter学习系列——common.php

    文件位于system/core/common.php,是框架核心文件. 该文件中定义了一系列的函数,都是框架运行中经常需要用到的.下面逐一介绍. is_php /** * Determines if ...