rt,已经重构三回了。QAQ....
by Hesan @ 2022-07-23 21:22:07
@[Hesan](/user/570081)
小数据就出了锅,建议找篇题解下来对拍
by Gokix @ 2022-07-23 21:33:49
@[Gokix](/user/150064) 好的rt
by Hesan @ 2022-07-23 21:36:22
找到错误了,在update中加了pushdown,好像是避免了爆long long .
```
void update(int x,int l,int r,const int L,const int R,int k){
if(L<=l && r<=R ){ tree[x]+=(r-l+1)*k%P;tree[x]%=P;tag[x]+=k;tag[x]%=P; return ;}
int mid=(l+r)>>1;
pushdown(x,l,r); //QAQ这里这里这里,还调了update和pushdown的位置。
if(mid>=L) update(x<<1,l,mid,L,R,k);
if(mid<R) update((x<<1)+1,mid+1,r,L,R,k);
tree[x]=tree[x<<1]+tree[(x<<1)+1];tree[x]%=P;
}
int query(int x,int l,int r,int L,int R){
if(L<=l && r<=R ) return tree[x];
int res=0;
if(tag[x]) pushdown(x,l,r);
int mid=(l+r)>>1;
if( L<=mid ) res+=query(x<<1,l,mid,L,R),res%=P;
if( mid<R ) res+=query((x<<1)+1,mid+1,r,L,R),res%=P;
return res;
}
```
by Hesan @ 2022-07-23 21:50:50
已AC.QAQ.........此帖完结
by Hesan @ 2022-07-23 21:51:44