20
c语言!!!!!!c++超时!!!!!
代码:
#include#include #include #include #include #include #include using namespace std;int a[1000005],c[1000005];int lowbit(int x){ return x&(-x);}int Sum(int x){ int s=0; while(x>0) { s+=c[x]; x=x-lowbit(x); } return s;} void Change (int i,int x,int n){ while(i<=n) { c[i]+=x; i+=lowbit(i); }}int main(){ int n,m,i,j,k,A,B; char st[20]; while((scanf("%d%d",&n,&m))!=EOF) { for(i=1;i<=n;i++) {//cin>>a[i]; scanf("%d",&a[i]); c[i]=0; } c[0]=0; for(i=1;i<=n;i++) for(j=i;j>i-lowbit(i);j--) c[i]+=a[j]; while(m--) { //cin>>st>>A>>B; scanf("%s%d%d",&st,&A,&B); if(st[0]=='A') Change(A,B,n); else { //cout< <