- 清点人数
- 2014-11-05 10:05:27 @
const
maxnum=100000;
var
n,k,m,p,i,j:longint;
c:char;
dasz,dat:array[0..maxnum] of longint;
function hslowbit(x:longint):longint;
begin
exit(x and (-x));
end;
function hsqiuhe(xi:longint):longint;
var
ptem:longint;
begin
ptem:=0;
while (xi>0) do
begin
inc(ptem,dasz[xi]);
dec(xi,hslowbit(xi));
end;
exit(ptem);
end;
procedure gccharu(xi,xx:longint);
begin
while (xi<=n) do
begin
inc(dasz[xi],xx);
inc(xi,hslowbit(xi));
end;
end;
begin
assign(input,'vjp1320.in');
reset(input);
assign(output,'vjp1320.out');
rewrite(output);
fillchar(dasz,sizeof(dasz),0);
readln(n,k);
for i:=1 to k do
begin
read(c);
read(m);
case (c) of
'A':begin
writeln(hsqiuhe(m));
readln;
end;
'B':begin
readln(p);
gccharu(m,p);
end;
'C':begin
readln(p);
gccharu(m,-p);
end;
end;
end;
close(input);
close(output);
end.
1 条评论
-
第七维度丶 LV 9 @ 2014-11-05 10:41:04
为什么要用这么厉害的东西→ → 不是一个一维数组模拟就好了么
- 1