求助本机、在线ide能#1能过,提交上去就挂了
查看原帖
求助本机、在线ide能#1能过,提交上去就挂了
746654
run_lec楼主2023/7/25 11:12

rt

#include<bits/stdc++.h>
#define maxn 150005
using namespace std;

void FR(){
	freopen("P3396_1.in","r",stdin);
	freopen("out","w",stdout);
}

const int split=388;

int a[maxn];
int pool[split][split];

int main(){
//	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//	FR();
	int n,T;
	cin>>n>>T;
//	cerr<<n<<' '<<T<<endl;
	char cmd;
	int x,y;
	for(int i=1;i<=n;++i) cin>>a[i];
	int rep=min(split,n);
	for(int i=1;i<=split;++i){//
		for(int j=1;j<=n;++j){
			pool[i][j%i]+=a[j];
		}
	}
//	for(int i=1;i<=10;++i){
//		for(int j=0;j<i;j++){
//			cerr<<pool[i][j]<<' ';
//		}
//		cerr<<endl;
//	}
	while(T--){
		cin>>cmd>>x>>y;
		if(cmd=='C'){
			for(int i=1;i<=split;++i){
				pool[i][x%i]+=-a[x]+y;
			}
			a[x]=y;
		}else{
			int res=0;
			if(x>split){
				for(int i=y;i<=n;i+=x) res+=a[i];
			}else{
				res=pool[x][y];
			}
			cout<<res<<endl;
		}
	}
	return 0;
} 
2023/7/25 11:12
加载中...