HDU 1166
来源:互联网 发布:数据分析可以考的证书 编辑:程序博客网 时间:2024/05/17 07:53
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;const int maxn = 50005;int c[maxn];int n;int lowbit(int t){ return t&(-t);}void add(int i,int t){ while(i<=n) { c[i]+=t; i=i+lowbit(i); }}int sum(int i){ int total=0; while(i>0) { total+=c[i]; i=i-lowbit(i); } return total;}int main(){ int T; scanf("%d",&T); int case1=1; while(T--) { memset(c,0,sizeof(c)); scanf("%d",&n); for(int i=1;i<=n;i++){ int x; scanf("%d",&x); add(i,x); } char s[10]; printf("Case %d:\n",case1++); while(scanf("%s",s)!=EOF) { int x,y; if(s[0]=='E') break; scanf("%d %d",&x,&y); if(s[0]=='A') add(x,y); else if(s[0]=='S') add(x,-y); else printf("%d\n",sum(y)-sum(x-1)); } } return 0;}
阅读全文
0 0
- hdu 1166
- hdu 1166
- hdu 1166
- hdu 1166
- HDU 1166
- HDU 1166
- hdu 1166 ~
- hdu-1166
- hdu 1166
- hdu 1166
- HDU 1166
- hdu 1166
- hdu 1166
- HDU 1166
- HDU 1166
- hdu 1166
- hdu 1166
- hdu 1166
- IPC-消息队列
- View组件
- 欢迎使用CSDN-markdown编辑器
- NSIS如何编写带参数的函数
- jQuery Mobile Data 属性
- HDU 1166
- nginx返回json或者文本格式详解
- java并发编程
- vue.js学习07之使用$.ajax和vue-resource实现OAuth的注册、登录、注销和API调用
- iOS七种手势
- JS之检索子字符串的search方法
- JS-2列瀑布流布局
- golang 将EBCDIC转成ASCII
- sublime-txt安装