申请加强数据,暴力能过
查看原帖
申请加强数据,暴力能过
767155
0v_0___SYC楼主2024/11/19 22:39
#include<bits/stdc++.h>
using namespace std;
int n,m,sum;
int a[150009];
int main(){
	cin >> n >> m;
	for(int i = 1;i<=n;i++){
		cin >> a[i];
		sum+=a[i];
	} 
	for(int q = 1;q<=m;q++){
		char cmd;
		int x,y;
		cin >> cmd >> x >> y;
		if(cmd == 'A'){
			int num = 0;
			if(x == 1){
				num = sum;
			}else{
				for(int i = y;i<=n;i+=x) num+=a[i];
			}
			
			cout << num << "\n";
		}else{
			sum-=a[x];
			a[x] = y;
			sum+=a[x];
		}
	}
}   

暴力就只加了一个统计数列和的优化就过了

就这么水灵灵的过了

2024/11/19 22:39
加载中...