| 记录编号 | 48543 | 评测结果 | AAAAAAAAAAAAAAAA | 
    
        | 题目名称 | 264.数列操作A | 最终得分 | 100 | 
    
        | 用户昵称 |  FrCsKOH | 是否通过 | 通过 | 
    
        | 代码语言 | Pascal | 运行时间 | 0.269 s | 
    
        | 提交时间 | 2012-11-05 21:39:36 | 内存使用 | 1.17 MiB | 
    
    
    
    		显示代码纯文本
		
		program C0264;
 const Be=262144;
 var t,Sse:byte;
     St:string;
     n,Cu,i,a,b,q:longint;
     f:array[1..Be] of longint;
 function Con(s:longint):longint;
  begin
   Con:=0;
   while 1<<Con<s+2 do inc(Con);
   Con:=1<<Con;
  end;
 function GetSum(l,r:longint):longint;
  begin
   GetSum:=0;
   inc(l,Cu-1);
   inc(r,Cu+1);
   while l xor r<>1 do begin
    if l and 1=0 then inc(GetSum,f[l+1]);
    if r and 1=1 then inc(GetSum,f[r-1]);
    l:=l>>1;
    r:=r>>1;
   end;
  end;
 procedure AddCk(t,k:longint);
  begin
   inc(t,Cu);
   while t<>1 do begin
    inc(f[t],k);
    t:=t>>1;
   end;
  end;
 begin
  assign(input,'shulie.in');
  reset(input);
  assign(output,'shulie.out');
  rewrite(output);
  readln(n);
  Cu:=Con(n);
  for i:=1 to n do read(f[i+Cu]);
  readln;
  for i:=Cu-1 downto 1 do f[i]:=f[i<<1]+f[i<<1+1];
  readln(q);
  for i:=1 to q do begin
   readln(St);
   while St[length(St)]=' ' do delete(St,length(St),1);
   t:=pos(' ',St);
   if St[1]='S' then Sse:=0 else Sse:=1;
   delete(St,1,t);
   t:=pos(' ',St);
   val(copy(St,1,t-1),a);
   val(copy(St,t+1,length(St)-t),b);
   case Sse of
    0:writeln(GetSum(a,b));
    1:AddCk(a,b);
   end;
  end;
  close(input);
  close(output);
 end.