Pagini recente » Cod sursa (job #1186567) | Cod sursa (job #3005018) | Cod sursa (job #1678278) | Cod sursa (job #876328) | Cod sursa (job #118368)
Cod sursa(job #118368)
type sir=array[1..15000] of integer;
var a,c:sir;
f,g:text;
m:longint;
n,s1,s2,z,y,i,j:longint;
x:longint;
begin
assign(f,'datorii.in'); reset(f);
assign(g,'datorii.out'); rewrite(g);
readln(f,n,m);
for i:=1 to n do read(f,a[i]);
for i:=1 to n do c[i]:=0;
readln(f);
for i:=1 to n do
begin
y:=((i)xor(i-1))and(i);
for j:=i+1-y to i do
c[i]:=c[i]+a[j];
end;
for i:=1 to m do
begin
readln(f,x,y,z);
if x=0 then
while y<=n do
begin
c[y]:=c[y]-z;
y:=y+((y)xor(y-1))and(y);
end
else
begin
s1:=0;
while z>0 do
begin
s1:=s1+c[z];
z:=z-((z)xor(z-1))and(z);
end;
dec(y);
s2:=0;
while y>0 do
begin
s2:=s2+c[y];
y:=y-((y)xor(y-1))and(y);
end;
writeln(g,s1-s2);
end;
end;
writeln(g);
close(g);
end.