本文共 1418 字,大约阅读时间需要 4 分钟。
#include #include #include #include #include #include #include #include #include #include #define REP(i,a,n) for(int i=a;i<=n;++i)#define PER(i,a,n) for(int i=n;i>=a;--i)#define hr putchar(10)#define pb push_back#define lc (o<<1)#define rc (lc|1)#define mid ((l+r)>>1)#define ls lc,l,mid#define rs rc,mid+1,r#define x first#define y second#define io std::ios::sync_with_stdio(false)#define endl '\n'using namespace std;typedef long long ll;typedef pair pii;const int P = 1e9+7, INF = 0x3f3f3f3f;ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}//headconst int N = 2e5+10;int n, q, pos;int a[N], w[N];ll s1[N<<2], s2[N<<2], sum, tot;void pu(int o) { s1[o]=s1[lc]+s1[rc]; s2[o]=(s2[lc]+s2[rc])%P;}void update(int o, int l, int r, int x, int v) { if (l==r) { s1[o] = v; s2[o] = (ll)v*a[l]%P; return; } if (mid>=x) update(ls,x,v); else update(rs,x,v); pu(o);}ll qry1(int o, int l, int r, int ql, int qr) { if (ql<=l&&r<=qr) return s1[o]; ll ans = 0; if (mid>=ql) ans+=qry1(ls,ql,qr); if (mid =qr) return qry2(ls,ql,qr); if (mid s1[lc]) sum-=s1[lc],find(rs,ql,qr); else find(ls,ql,qr); return; } if (mid>=ql) find(ls,ql,qr); if (mid
转载于:https://www.cnblogs.com/uid001/p/10754367.html