【数据结构】——线段树板子
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 int read(){ 5 int x=0,f=1; 6 char c=getchar(); 7 while(!isdigit(c)){ 8 if(c=='-') f=-1; 9 c=getchar(); 10 } 11 while(isdigit(c)){ 12 x=(x<<1)+(x<<3)+(c^48); 13 c=getchar(); 14 } 15 return x*f; 16 } 17 const int N=1e5+10; 18 int n,m,p; 19 int a[N]; 20 struct tree{ 21 ll sum[N<<2]; 22 ll add[N<<2],mul[N<<2]; 23 int ls(int o){return o<<1;} 24 int rs(int o){return o<<1|1;} 25 void pushup(int o){ 26 sum[o]=(sum[ls(o)]+sum[rs(o)])%p; 27 } 28 void pushdown(int o,int l,int r){ 29 int mid=(l+r)>>1; 30 sum[ls(o)]=(sum[ls(o)]*mul