ioi2001,没啥可说的 mobile phones,水过 program pku_1195; var c:array[0..1025,0..1025] of longint; a:array[0..1025] of longint; n:longint; {-----------------------} procedure change(x,y,d:longint); var t:longint; begin while x<=n do begin t:=y; while t<=n do begin c[x,t]:=c[x,t]+d; t:=t+a[t]; end; x:=x+a[x]; end; end; {-----------------------} function getsum(x,y:longint):longint; var t,tot:longint; begin tot:=0; while x>0 do begin t:=y; while t>0 do begin tot:=tot+c[x,t]; t:=t-a[t]; end; x:=x-a[x]; end; exit(tot); end; {-----------------------} procedure main; var i,t,d,x,y,p,q,ans:longint; begin fillchar(c,sizeof(c),0); for i:=1 to 1024 do a[i]:=i and (i xor (i-1)); while true do begin read(t); if t=3 then break; case t of 0:readln(n); 1:begin readln(x,y,d); inc(x);inc(y); change(x,y,d); end; 2:begin readln(x,y,p,q); inc(x);inc(y); inc(p);inc(q); ans:=getsum(p,q); inc(ans,getsum(x-1,y-1)); dec(ans,getsum(x-1,q)); dec(ans,getsum(p,y-1)); writeln(ans); end; end; end; end; {-----------------------} begin main; end.