- 校门外的树
- 2009-03-17 16:17:37 @
type ad=array[0..60010] of longint;
var c1,c2:ad;
n,m:longint;
i,j,l,r,k:longint;
function lowbit(x:longint):longint;
begin
lowbit:=x and (x xor(x-1));
end;
procedure updata(var c:ad;x:longint);
var p:longint;
begin
p:=x;
while p0 do
begin
sum:=sum+c[p];
p:=p-lowbit(p);
end;
getsum:=sum;
end;
{c1是左括号,c2是右括号}
//---|---|---|---|---|main---|---|---|---|---|---|---|--
begin
readln(n,m);
for i:=1 to m do
begin
readln(k,l,r);
if k=1 then begin
updata(c1,l); updata(c2,r);
end
else begin
r:=getsum(c1,r-1)-getsum(c2,l-1);
writeln(r);
end;
end;
end.
3 条评论
-
Hoshino_kaede LV 3 @ 2022-08-01 16:18:38
13年前耶
-
2009-03-18 18:08:08@
不是过了吗
-
2009-03-17 16:25:37@
(Invalid img)
难道就没人看吗?
- 1