WA70分
结果我下载数据点测试,竟然没有输出???
我用文件读写又来了一遍,还是没有!(离谱)谁知道为什么?帮忙修改一下可以吗,谢谢
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,a[100050];
int sz[131073];
int main()
{
//freopen("P3374_2.in","r",stdin);
//freopen("P3374_2.out","w",stdout);
cin>>n>>m;
int op,x,y;
for(int i=1;i<=n;i++)
{
cin>>a[i];
sz[i]=a[i];
int j=1,z=i;
while(i-j>0&&((z&1)==0))
{
sz[i]+=sz[i-j];
j*=2;
z/=2;
}
//cout<<sz[i]<<' ';
}
//cout<<'\n';
for(int i=1;i<=m;i++)
{
cin>>op>>x>>y;
if(op==1)
{
while(x<131072)
{
sz[x]+=y;
x+=(x&(-x));
}
//for(int i=1;i<=n;i++) cout<<sz[i]<<' ';
//cout<<'\n';
}
if(op==2)
{
int x_=0,y_=0;
x--;
while(x)
{
//cout<<x<<' ';
x_+=sz[x];
x-=(x&(-x));
}
//cout<<'\n';
while(y)
{
//cout<<y<<' ';
y_+=sz[y];
y-=(y&(-y));
}
//cout<<'\n';
cout<<y_-x_<<'\n';
}
}
return 0;
}