HDU 1166 敌兵布阵(树状数组)
来源:互联网 发布:win10软件乱码 编辑:程序博客网 时间:2024/06/07 15:36
请不要随便指点别人该怎么做、每个人的人生都应该自己掌握、你给不了别人一切、你也不懂别人的忧伤、
微笑不代表快乐、哭泣不一定悲伤
不努力怎么让关心你的人幸福、不努力怎么让看不起你的人绝望、
我用生命在奋斗——lx_Zz
—————————————————————————————————————————————————————————————
————————————————————————— 华丽的分割线 ————————————————————————————
—————————————————————————————————————————————————————————————
107327682014-05-13 13:39:16Accepted1166156MS632K1480 BC++给我再去相....上课前切一道树状数组
7分钟树状数组搞定、上课去了。。。O(∩_∩)O哈哈~
/* 题目: HDU 1166 *//* 作者: lx_Zz *//* 时间: 2014.5.13 */#include<cstdio>#include<queue>#include<vector>#include<map>#include<string>#include<iostream>#include<cmath>#include<cstdlib>#include<cstring>#include<algorithm>using namespace std;#define INF 0x7fffffff#define LL __int64int n;const int maxn=50005;int num[maxn];int c[maxn];int lowbit(int x){return x&(-x);}void add(int x,int d){while(x<=n){c[x]+=d;x+=lowbit(x);}}int sum(int x){int ret=0;while(x>0){ret+=c[x];x-=lowbit(x);}return ret;}int main(){ //freopen("C:\\Users\\终将我要华丽的逆袭\\Desktop\\lx_Zz_in.txt","r",stdin); //freopen("C:\\Users\\终将我要华丽的逆袭\\Desktop\\lx_Zz_out.txt","w",stdout);int T;int cas=1;scanf("%d",&T);while(T--){printf("Case %d:\n",cas++);memset(c,0,sizeof(c));scanf("%d",&n);for(int i=1;i<=n;i++){scanf("%d",&num[i]);add(i,num[i]);}while(true){char str[15];scanf("%s",str);if(strcmp(str,"End")==0)break;else if(strcmp(str,"Add")==0){int a,b;scanf("%d%d",&a,&b);add(a,b);}else if(strcmp(str,"Sub")==0){int a,b;scanf("%d%d",&a,&b);add(a,-b);}else if(strcmp(str,"Query")==0){int a,b;scanf("%d%d",&a,&b);int ans=sum(b)-sum(a-1);printf("%d\n",ans);}}} return 0;}
- hdu 1166 敌兵布阵 (树状数组)
- (树状数组) hdu 1166 敌兵布阵
- HDU 1166 敌兵布阵【树状数组】
- HDU-1166-敌兵布阵(树状数组)
- hdu 1166 敌兵布阵 <树状数组>
- hdu 1166 敌兵布阵(裸树状数组)
- hdu - 1166 - 敌兵布阵(树状数组)
- hdu 1166 敌兵布阵【树状数组入门】
- hdu 1166 敌兵布阵 树状数组
- hdu hdoj 1166 敌兵布阵 树状数组
- HDU--1166 -- 敌兵布阵 [树状数组]
- hdu 1166 敌兵布阵 (树状数组)
- HDU 1166 - 敌兵布阵(树状数组)
- 树状数组-再说敌兵布阵(HDU 1166)
- hdu 1166 敌兵布阵 ( 树状数组 )
- HDU-1166 敌兵布阵 简单树状数组
- HDU 1166 敌兵布阵(树状数组)
- HDU 1166 敌兵布阵(树状数组)
- javascript 判断文件名
- cacti安装配置
- 序列式容器
- cp直接覆盖不提示按Y/N的方法
- git基本环境配置和创建一个项目Demo
- HDU 1166 敌兵布阵(树状数组)
- Shell中判定字符串为空
- 关于xdais
- com.wanju.project001.zonghe.common.interfaces ,mybatis异常
- Android 图片三级缓存之内存缓存(告别软引用(SoftRefrerence)和弱引用(WeakReference))
- VS2010入门
- Android SkImageDecoder::Factory returned null
- POJ iCow
- 学习笔记20140513