#include<stdio.h> #include<string.h> int arr[50005]; int c[50005]; int n; int lowbit(int x) { x = x & (x ^ (x-1)); return x; } void change(int x,int y) { while(x <= n) { c[x] += y; x += lowbit(x); } } int get_sum(int x) { int sum = 0; while(x >= 1){ sum += c[x]; x -= lowbit(x); } return sum; } int main() { int tcase; int i; int a,b; int sum; int walk = 0; char str[10]; scanf("%d",&tcase); while(tcase--){ arr[0] = 0; scanf("%d",&n); for(i = 1;i <= n;i++){ scanf("%d",&arr[i]); arr[i] += arr[i-1]; c[i] = arr[i]-arr[i-lowbit(i)]; } printf("Case %d:/n",++walk); while(1){ scanf("%s",str); if(!strcmp(str,"Query")){ scanf("%d %d",&a,&b); printf("%d/n",get_sum(b)-get_sum(a-1)); } if(!strcmp(str,"Add")){ scanf("%d %d",&a,&b); change(a,b); } if(!strcmp(str,"Sub")){ scanf("%d %d",&a,&b); change(a,-b); } if(!strcmp(str,"End")) break; } } return 0; }