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 ...
随机推荐
- 阿里巴巴分布式服务框架 Dubbo
1.Dubbo是阿里巴巴内部的SOA服务化治理方案的核心框架,每天为2000+ 个服务提供3,000,000,000+ 次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点.Dubbo自2011年开源 ...
- 基于CXF框架下的SOAP Webservice服务端接口开发
最近对webservice 进行入门学习,网上也是找了很多的学习资料.总得感觉就是这了解点,那了解点.感觉不够系统,不够容易入门.差不多断断续续看了一个星期了,今天小有成果,把客户端,服务端都搞定了. ...
- 【BZOJ】【2527】【POI2011】Meteors
整体二分+树状数组 整体二分……感谢zyf提供的入门题 简单粗暴的做法:枚举每一个国家,二分他的$w_i$,然后计算……然而这样效率很低…… 整体二分就是:对所有的国家一起进行二分,$w_i$在mid ...
- 在Java Web程序中使用Hibernate
在Java Web程序中使用Hibernate与普通Java程序一样.本文中将使用Servlet和JSP结合Hibernate实现数据库表的增删改查操作. Web程序中,hibernate.cfg.x ...
- spring中ApplicationContextAware接口使用理解
一.这个接口有什么用?当一个类实现了这个接口(ApplicationContextAware)之后,这个类就可以方便获得ApplicationContext中的所有bean.换句话说,就是这个类可以直 ...
- after the first ten days
This is the first week for me to speak English formally. There’re two main problems: First, I’m scar ...
- 使用jQuery在上传图片之前实现缩略图预览
使用jQuery在上传图片之前实现缩略图预览 jQuery代码 01 $("#uploadImage").on("change", function(){ 02 ...
- Python3 写Windows Service服务程序
用Python开发Windows Service,用Python来做这个事情必须要借助第三方模块pywin32,下载路径:https://pypi.org/project/pywin32/#files ...
- 安装Oracle之后解决掉的问题分享
TNS-03505: 无法解析名称 在测试tnsping的时候始终显示这么个问题. ...
- debug输出rect,size和point的宏
#define NSLogRect(rect) NSLog(@"%s x:%.4f, y:%.4f, w:%.4f, h:%.4f", #rect, rect.origin.x, ...