HDUOJ -----Color the ball
Color the ball
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7497 Accepted Submission(s): 3865
当N = 0,输入结束。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define maxn 100000
int aa[maxn+];
int nn;
int lowbit(int x)
{
return x&(-x);
}
void ope(int x,int val)
{
while(x<=nn)
{
aa[x]+=val;
x+=lowbit(x);
}
}
int sum(int x)
{
int ans=;
while(x>)
{
ans+=aa[x];
x-=lowbit(x);
}
return ans;
}
int main()
{
int i,a,b;
while(scanf("%d",&nn),nn)
{
memset(aa,,sizeof(aa));
for(i=;i<nn;i++)
{
scanf("%d%d",&a,&b);
ope(a,);
ope(b+,-);
}
printf("%d",sum());
for(i=;i<=nn;i++)
printf(" %d",sum(i));
putchar();
}
return ;
}
HDUOJ -----Color the ball的更多相关文章
- HDU 1556 Color the ball(线段树区间更新)
Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题 ...
- hdu 1556:Color the ball(第二类树状数组 —— 区间更新,点求和)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 1556:Color the ball(线段树,区间更新,经典题)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- Color the Ball[HDU1199]
Color the Ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- 线段树--Color the ball(多次染色问题)
K - Color the ball Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- hdu 1199 Color the Ball
http://acm.hdu.edu.cn/showproblem.php?pid=1199 Color the Ball Time Limit: 2000/1000 MS (Java/Others) ...
- Color the ball HDOJ--1556
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdoj 1556 Color the ball【线段树区间更新】
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 1199 Color the Ball(离散化线段树)
Color the Ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
随机推荐
- 对只转发结果集的无效操作:last
调用时候发生这样一个错误: SQLException: 对只转发结果集的无效操作:last 原因是按照缺省方式打开的ResultSet不支持结果集cursor的回滚 如果想要完成上述操作,要在生成St ...
- 《深入理解C指针》
<深入理解C指针> 基本信息 原书名:Understanding and using C pointers 作者: (美)Richard Reese 译者: 陈晓亮 丛书名: 图灵程序设计 ...
- Java学习之路(转)
我也搞了几年JAVA了.因为一向懒惰,没有成为大牛,仅仅是一普通程序员,不爱玩社交站点.不爱玩微博,只有喜欢百度贴吧,潜水非常久了,手痒来给新人分享下从新手成长为老鸟的已见,也刷刷存在感,应该不比曝照 ...
- NLP 依存分析
NLP 依存分析 https://blog.csdn.net/sinat_33741547/article/details/79258045
- Android中远程Service浅析
上一篇文章中简单的写了一下关于Android中Service的两种启动方式,不过都是本地的服务,今天就简单的写下关于Android中远程Service的使用,学习之前先了解两个概念,AIDL( And ...
- Golang 中使用多维 map
http://tnt.wicast.tk/2015/11/02/golang-multiple-dimension-map/ Golang 的 XML/JSON 解析库乍看使用起来很方便,只要构造一样 ...
- 如何在Linux上面安装GCC 4.1.2
安装步骤: 1.首先下载GCC 4.1.2的source code package: $ wget http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.1.2/gcc-4 ...
- Bootstrap全局CSS样式之表格
.table--基础表格样式. .table-striped--给<tbody>之内的每一行添加斑马条纹样式: .table-bordered--为表格添加边框: .table-hover ...
- vs2013 密钥_
vs2013 密钥 最佳答案: BWG7X-J98B3-W34RT-33B3R-JVYW9
- svn自助改动password(PHP脚本实现)
#创建脚本文件夹 mkdir -p /var/www/svn/svntools #创建apache配置文件 touch /etc/httpd/conf.d/alias.conf #输入下面内容: Al ...