#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ma 1145141
using namespace std;
inline ll read(){
char ch=getchar();
ll x=0,f=1;
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;
}
inline void write(ll x){
char ch[20];
ll len=0;
if(x<0){
putchar((1<<5)+(1<<3)+(1<<2)+1);
x=~x+1;
}
do{
ch[len++]=x%10+(1<<4)+(1<<5);
x/=10;
}while(x>0);
for(ll i=len-1;i>=0;i--) putchar(ch[i]);
return;
}
ll n,a[ma],m;
int main(){
n=read(),m=read();
for(ll i=1;i<=n;i++) a[i]=read();
for(ll i=1;i<=m;i++){
char op=getchar();
ll x=read(),y=read();
if(op=='A'){
ll ans=0;
if(y==0) y=x;
for(ll j=y;j<=n;j+=x) ans+=a[j];
cout<<ans<<endl;
}
if(op=='C'){
a[x]=y;
}
}
return 0;
}
能过样例,但测试点全wa,数据对比后发现差值相同
如
| out | ans |
|---|---|
| 506389 | 505786 |
| 65039 | 64436 |
| 均差603 |