为什么全错
  • 板块P2068 统计和
  • 楼主chenkuo
  • 当前回复5
  • 已保存回复5
  • 发布时间2022/8/19 17:41
  • 上次更新2023/10/27 14:34:18
查看原帖
为什么全错
443023
chenkuo楼主2022/8/19 17:41

0分,怎么办,大佬帮忙看看好吗

#include<bits/stdc++.h>
using namespace std;
long long m,n,a,b,e[1000001];
char q;
void change(long long x,long long shu){
	while(x<m){
		e[x]+=shu;
		x+=(x&(-x));
	}
}
long long sum(long long x){
	long long s=0;
	while(x>0){
		s+=e[x];
		x-=(x&(-x));
	}
	return s;
}
int main(){
	cin>>m>>n;
	for(long long i=1;i<=n;i++){
		cin>>q>>a>>b;
		if(q=='x'){
			change(a,b);
		}
		if(q=='y'){
			cout<<sum(b)-sum(a-1)<<endl;
		}
	} 
}
2022/8/19 17:41
加载中...