求助,WA54pts
  • 板块P3396 哈希冲突
  • 楼主luoyx
  • 当前回复7
  • 已保存回复7
  • 发布时间2023/8/7 20:16
  • 上次更新2023/11/3 05:19:37
查看原帖
求助,WA54pts
520056
luoyx楼主2023/8/7 20:16
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,q;
const int N=1e5+5;
int a[N],siz;
int f[710][710];

signed main(){
	cin>>n>>q;
	siz=sqrt(n);
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		for(int p=1;p<=siz;p++){
			f[p][i%p]+=a[i];
		}
	}
	char c;
	int x,k;
	while(q--){
		scanf(" %c",&c);
		cin>>x>>k;
		if(c=='A'){
			if(x<=siz) cout<<f[x][k]<<endl;
			else{
				int ans=0;
				for(int j=k;j<=n;j+=x){
					ans+=a[j];
				}
				cout<<ans<<endl;
			}
		}
		else{
			for(int i=1;i<=siz;i++){
				f[i][x%i]+=k-a[x];
			}
			a[x]=k;
		}
	}
}
2023/8/7 20:16
加载中...