标签:
Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
///1085422276 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<queue> #include<cmath> #include<map> #include<bitset> #include<set> #include<vector> using namespace std ; typedef long long ll; #define mem(a) memset(a,0,sizeof(a)) #define meminf(a) memset(a,127,sizeof(a)); #define TS printf("111111\n"); #define FOR(i,a,b) for( int i=a;i<=b;i++) #define FORJ(i,a,b) for(int i=a;i>=b;i--) #define READ(a) scanf("%d",&a) #define g 9.8 #define mod 100000000 #define eps 0.0000001 #define maxn 50000+1 inline ll read() { ll x=0,f=1; char ch=getchar(); while(ch<‘0‘||ch>‘9‘) { if(ch==‘-‘)f=-1; ch=getchar(); } while(ch>=‘0‘&&ch<=‘9‘) { x=x*10+ch-‘0‘; ch=getchar(); } return x*f; } //**************************************** int c[maxn][11][11],s[maxn],n; int lowbit(int x){return x&(-x);} void update(int a,int b,int x,int v) { while(x<=n) { c[x][a][b]+=v; x+=lowbit(x); } } int get(int x,int a) { int sum=0; while(x>0) { FOR(i,1,10) sum+=c[x][i][a%i]; x-=lowbit(x); } return sum; } int main() { while(READ(n)!=EOF) { mem(c); FOR(i,1,n) { scanf("%d",&s[i]); } int q=read(); int t,a,b,k,add; FOR(i,1,q) { scanf("%d",&t); if(t==1) { scanf("%d%d%d%d",&a,&b,&k,&add); update(k,a%k,a,add); update(k,a%k,b+1,-add); } else { scanf("%d",&a); printf("%d\n",get(a,a)+s[a]); } } } return 0; }
标签:
原文地址:http://www.cnblogs.com/zxhl/p/4793394.html