hdu1166树状数组模板题
来源:互联网 发布:星空棒棒糖淘宝网 编辑:程序博客网 时间:2024/05/21 10:33
#define DeBUG#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>#include <vector>#include <stack>#include <queue>#include <string>#include <set>#include <sstream>#include <map>#include <bitset>using namespace std ;#define zero {0}#define INF 2000000000#define EPS 1e-6typedef long long LL;const double PI = acos(-1.0);//#pragma comment(linker, "/STACK:102400000,102400000")inline int sgn(double x){ return fabs(x) < EPS ? 0 : (x < 0 ? -1 : 1);}#define MAX 50005inline int lowbit(int x){ return (x & (-x));}int a[MAX], n;void add(int index, int num){ while (index <= n) { a[index] += num; index += lowbit(index); }}int Sum(int x){ int sum = 0; while (x > 0) { sum += a[x]; x -= lowbit(x); } return sum;}int cnt=1;int main(){#ifdef DeBUGs freopen("//home//amb//桌面//1.in", "r", stdin);#endif int T; scanf("%d", &T); while (T--) { memset(a,0,sizeof(a)); scanf("%d",&n); printf("Case %d:\n", cnt++); int it; for(int i=1;i<=n;i++) { scanf("%d",&it); add(i,it); } char s[10]; int a1,a2; while(scanf("%s",s),s[0]!='E') { scanf("%d%d",&a1,&a2); if(s[0]=='A') add(a1,a2); else if(s[0]=='S') add(a1,-a2); else printf("%d\n", Sum(a2)-Sum(a1-1)); } } return 0;}
0 0
- hdu1166树状数组模板题
- 树状数组模板题hdu1166
- hdu1166-树状数组模板题
- 树状数组模板 HDU1166
- 树状数组模板题—hdu1166+poj2352
- hdu1166及树状数组模板
- hdu1166敌兵布阵(树状数组模板题)
- hdu1166敌兵布阵<树状数组---模板>
- HDU1166——树状数组模板
- hdu1166 (树状数组 简单题)
- 树状数组-简单题(HDU1166)
- 树状数组简单题(HDU1166)
- 树状数组简单题(HDU1166)
- HDU1166 敌兵布阵 树状数组水题
- hdu1166树状数组
- HDU1166树状数组
- hdu1166 树状数组
- hdu1166树状数组
- Create A Repo
- 安卓访问webservice出现android.os.NetworkOnMainThreadException异常
- xcode 快捷键
- php--mixed
- Dynamo和Cassandra中用到的Merkle tree
- hdu1166树状数组模板题
- Java-reflex反射机制
- 各种数据库的区别?
- cocos2d-x 常用代码、高频使用代码【CCLayer、CCEditBox编辑框、CCControlButton按钮、CCLabelTTF标签、CCSpriteBatchNode渲染、CCMen】
- 关联、组合、聚合、依赖关系比较(转载)
- iOS 使用FMDB进行数据库操作
- error C2036: 'PVOID' : unknown size
- SVD因式分解实现协同过滤-及源码实现
- 【突发】纽约曼哈顿中城发生爆炸