hdu 1556 Color the ball
来源:互联网 发布:maya mac注册机打不开 编辑:程序博客网 时间:2024/05/16 16:22
向上统计,向下修改
#include <cstdio>#include <cstring>#include <iostream>using namespace std;int const MAXN = 100010;int c[MAXN * 4],a[MAXN];int n;int Lowit(int x){ return x & (-x);}void Add(int x,int d){ while(x > 0){ c[x] += d; x -= Lowit(x); }}int Sum(int x){ int ret = 0; while(x <= n){ ret += c[x]; x += Lowit(x); } return ret;}int main(){ while(~scanf("%d",&n),n){ memset(c,0,sizeof(c)); for(int i = 0;i < n;i++){ int a,b; scanf("%d%d",&a,&b); Add(b,1); Add(a - 1,-1); } for(int i = 1;i < n;i++){ printf("%d ",Sum(i)); } printf("%d\n",Sum(n)); } return 0;}
0 0
- hdu 1556 color the ball
- hdu 1556Color the ball
- HDU 1556 - Color the ball
- Hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- hdu 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- HDU 1556 Color the ball
- java查找修改文件
- 简单的PDO数据库操作类
- ASIHTTPRequest的使用——介绍说明
- 如何写一个最简单的操作系统
- 设计模式学习笔记——门面模式
- hdu 1556 Color the ball
- hdu 3294 Girls' research
- 强大的vim配置文件,让编程更随意
- Cocos2dx项目anroid真机测试报告
- 请修改append函数,利用这个函数实现
- Spark SQL Catalyst源码分析之SqlParser
- POJ-3069-Saruman's Army
- Principle of Computing (Python)学习笔记(6) Recursion + Word Wrangler
- 如何将dataGridView 导出到Excel