标签:
Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4000 Accepted Submission(s): 1243
int d[maxn][12][12]; int a[maxn]; int n; int lowbit(int x) { return x&(-x); } void update2(int x,int num,int k,int mod) { while(x>0) { d[x][k][mod]+=num; x-=lowbit(x); } } int getSum1(int x,int k) int s=0; while(x<=n) { REP_1(i,10) { s+=d[x][i][k%i]; } x+=lowbit(x); } return s; } int main() { while(RD(n)!=-1) { REP_1(i,n) RD(a[i]); memset(d,0,sizeof(d)); int q; RD(q); while(q--) { int t; RD(t); if(t==1) { int l,r,k,c; RD(l),RD(r),RD(k),RD(c); update2(r,c,k,l%k); update2(l-1,-c,k,l%k); } if(t==2) { int c; RD(c); printf("%d\n",getSum1(c,c)+a[c]); } } } }
HDU 4267 A Simple Problem with Integers 多个树状数组
标签:
原文地址:http://www.cnblogs.com/qscqesze/p/4333266.html