#include<cstdio>
#include<string>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<cstring>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
#include<cctype>
#include<stack>
#include<sstream>
#include<list>
#include<numeric>
#define debug() puts("++++")
#define gcd(a,b) __gcd(a,b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a,b,sizeof(a))
#define sz size()
#define be begin()
#define pu push_up
#define pd push_down
#define cl clear()
#define lowbit(x) -x&x
#define all 1,n,1
#define rep(i,x,n) for(int i=(x); i<(n); i++)
#define in freopen("in.in","r",stdin)
#define out freopen("out.out","w",stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const ll LNF = 1e18;
const int maxn = 1e5;
const int maxm = 1e6 + 10;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int dx[] = {-1,1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
int dir[4][2] = {{0,1},{0,-1},{-1,0},{1,0}};
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int sum[maxn<<2]; void PushUp(int rt)
{
sum[rt]=sum[rt<<1]+sum[rt<<1|1];
}
void build(int l,int r,int rt)
{
if(l==r)
{
scanf("%d",&sum[rt]);
return ;
}
int m = (l+r)>>1;
build(lson);
build(rson);
PushUp(rt);
}
void update(int p,int add,int l,int r,int rt)
{
if(l==r)
{
sum[rt] += add;
return ;
}
int m = (l+r)>>1;
if(p<=m) update(p,add,lson);
else update(p,add,rson);
PushUp(rt);
}
int query(int L,int R,int l,int r,int rt)
{
if(L<=l && r<=R)
{
return sum[rt];
}
int m = (l+r)>>1;
int ans = 0;
if(L<=m) ans += query(L,R,lson);
if(R>m) ans += query(L,R,rson);
return ans;
} int main()
{
int T,n;
scanf("%d",&T);
for(int cas=1;cas<=T;cas++)
{
printf("Case %d:\n",cas);
scanf("%d",&n);
build(1,n,1);
char op[15];
while(scanf("%s",op))
{
if(op[0]=='E') break;
int a,b;
scanf("%d%d",&a,&b);
if(op[0]=='Q')
{
printf("%d\n",query(a,b,1,n,1));
}
else if(op[0]=='S') update(a,-b,1,n,1);
else update(a,b,1,n,1);
}
}
}

最新文章

  1. Unslider.js Tiny Sample
  2. 全球首个全流程跨平台界面开发套件,PowerUI分析
  3. DDNS
  4. TCP 介绍
  5. Struts2在Action中访问WEB资源
  6. C# 反射的简单用法
  7. Android开源项目——带图标文字的底部导航栏IconTabPageIndicator
  8. 读zepto源码之工具函数
  9. SQL表的基本操作
  10. 潭州课堂25班:Ph201805201 爬虫高级 第十三 课 代理池爬虫检测部分 (课堂笔记)
  11. Zephyr学习(一)Zephyr介绍
  12. BZOJ1834[ZJOI2010]网络扩容——最小费用最大流+最大流
  13. git push -f
  14. gb2312提交的url编码转换成utf8的查询
  15. 安装hyperledger fabric V1.0.1
  16. 放大Button热区的方法哟
  17. js函数调用二种常用方法的例子
  18. NodeJS之express的路由浅析
  19. 迷你MVVM框架 avalonjs 学习教程17、avalon的一些配置项
  20. R语言实战实现基于用户的简单的推荐系统(数量较少)

热门文章

  1. svn稀疏目录--通过设置工作目录的深度(depth)实现目录树的部分签出
  2. vijos 1002 简单压缩+DP
  3. 2015/9/20 Python基础(16):类和实例
  4. Jmeter-8-FTP测试
  5. 【CodeForces】788E New task
  6. GXC 钱包部署
  7. 20、redis和memcached比较?
  8. A题 hdu 1235 统计同成绩学生人数
  9. hdu 1241Oil Deposits(BFS)
  10. 以下suse11.3x64可以安装pycrypto-2.6.1