/ Vijos / 讨论 / 问答 /

# 谁来帮我解释一下为啥会re三个点（好像不是数组的问题）

``````#include<bits/stdc++.h>
using namespace std;
struct setree{
long long l,r;
#define  l(x)  tree[x].l
#define  r(x)  tree[x].r
#define  sum(x)  tree[x].sum
} tree[10000000];
long long a[10000001],n,m,s;
void build(int p,int l,int r)
{
l(p)=l;r(p)=r;
if(l==r){  sum(p)=a[l]%s;return ;}
int mid=(l+r)/2;
build(p*2,l,mid);
build (p*2+1,mid+1,r);
sum(p)=(sum(p*2)+sum(p*2+1))%s;
}
void spread(int p,int s)
{
{
}
{
}
}
void change1(int p,int l,int r,int d,int s)
{
if(l<=l(p)&&r>=r(p))
{
sum(p)=(sum(p)%s+d*(r(p)-l(p)+1)%s)%s;
return;
}
int mid=(l(p)+r(p))%s/2;
if(l<=mid)change1(p*2,l,r,d,s);
if(r>mid)change1(p*2+1,l,r,d,s);
sum(p)=(sum(p*2)+sum(p*2+1))%s;
}
void change2(int p,int l,int r,int d,int s)
{
if(l<=l(p)&&r>=r(p))
{
sum(p)=(sum(p)*d)%s;
return ;
}
int mid=(l(p)+r(p))%s/2;
if(l<=mid)change2(p*2,l,r,d,s);
if(r>mid)change2(p*2+1,l,r,d,s);
sum(p)=(sum(p*2)+sum(p*2+1))%s;
}
long long ask(int p,int l,int r,int s)
{
if(l<=l(p)&&r>=r(p))
{
return sum(p);
}

int mid=(l(p)+r(p))/2;
long long val=0;
return val%s;

}
int main()
{
long long b,c,d,k;
cin>>n>>s;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
build (1,1,n);
cin>>m;
while(m--)
{
cin>>b;
if(b==3)
{
scanf("%d%d",&c,&d);
}
if(b==1)
{scanf("%d%d%d",&c,&d,&k);
change2(1,c,d,k,s);
}
if(b==2)
{scanf("%d%d%d",&c,&d,&k);
change1(1,c,d,k,s);
}
}
return 0;
}
``````