哪位大神能帮忙看看,是哪里的问题?
#include<iostream>
using namespace std;
typedef long long LL;
int p;
LL a[100005];
struct node{
int l,r;
LL h,j,c;
}tr[400005];
void pushup(int x){
tr[x].h=(tr[x<<1].h+tr[x<<1|1].h)%p;
}
void pushdown(int x){
tr[x<<1].j=(tr[x<<1].j+tr[x].j)%p;
tr[x<<1].h=(LL(tr[x].j*(tr[x<<1].r-tr[x<<1].l+1))%p+tr[x<<1].h)%p;
tr[x<<1|1].j=(tr[x<<1|1].j+tr[x].j)%p;
tr[x<<1|1].h=(LL(tr[x].j*(tr[x<<1|1].r-tr[x<<1|1].l+1))%p+tr[x<<1|1].h)%p;
tr[x<<1].c=LL(tr[x<<1].c*tr[x].c)%p;
tr[x<<1].h=LL(tr[x<<1].h*tr[x].c)%p;
tr[x<<1|1].c=LL(tr[x<<1|1].c*tr[x].c)%p;
tr[x<<1|1].h=LL(tr[x<<1|1].h*tr[x].c)%p;
tr[x].j=0;
tr[x].c=1;
}
void build(int l,int r,int x){
tr[x].c=1;
if(l==r){
tr[x]={l,r,a[l]%p};
return;
}
tr[x].l=l;
tr[x].r=r;
int mid=l+r>>1;
build(l,mid,x<<1);
build(mid+1,r,x<<1|1);
pushup(x);
}
void quj(int l,int r,int x,LL num){
pushdown(x);
if(tr[x].l>=l&&tr[x].r<=r){
tr[x].h=(tr[x].h+(LL(tr[x].r-tr[x].l+1)*num)%p)%p;
tr[x].j=num;
return;
}
int mid=tr[x].l+tr[x].r>>1;
if(l<=mid)
quj(l,r,x<<1,num);
if(r>mid)
quj(l,r,x<<1|1,num);
pushup(x);
}
void quc(int l,int r,int x,LL num){
pushdown(x);
if(tr[x].l>=l&&tr[x].r<=r){
tr[x].h=LL(tr[x].h*num)%p;
tr[x].c=num;
return;
}
int mid=tr[x].l+tr[x].r>>1;
if(l<=mid)
quc(l,r,x<<1,num);
if(r>mid)
quc(l,r,x<<1|1,num);
pushup(x);
}
int search(int l,int r,int x){
pushdown(x);
if(tr[x].l>=l&&tr[x].r<=r)
return tr[x].h;
int mid=tr[x].l+tr[x].r>>1,res=0;
if(l<=mid)
res=(res+search(l,r,x<<1))%p;
if(r>mid)
res=(res+search(l,r,x<<1|1))%p;
return res;
}
int main(){
int n,m;
scanf("%d%d%d",&n,&m,&p);
for(int i=1;i<=n;i++)
scanf("%lld",&a[i]);
build(1,n,1);
while(m--){
int type,l,r;
scanf("%d%d%d",&type,&l,&r);
if(type==1){
LL num;
scanf("%lld",&num);
num%=p;
quc(l,r,1,num);
}
else if(type==2){
LL num;
scanf("%lld",&num);
num%=p;
quj(l,r,1,num);
}
else
printf("%d\n",search(l,r,1));
}
return 0;
}