题意:给你n个方程
每次询问l,r,x, 问你 从第l到第r个方程f(x)的求和
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn =2e5+10;
ll rd() {ll t;scanf("%I64d",&t);return t;}
#define en '\n'
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
const int mo=1e9;
const int maxm=maxn*133;
int tot=0;
int ls[maxm],rs[maxm],rt[maxm];
ll val[maxm][2];
inline void up(int x){
val[x][0]=val[ls[x]][0]+val[rs[x]][0];
val[x][1]=val[ls[x]][1]+val[rs[x]][1];
}
void update(int &x,int y,int l,int r,int pos,int v,int vv){
x=++tot;
ls[x]=ls[y];rs[x]=rs[y];
val[x][0]=val[y][0];val[x][1]=val[y][1];
val[x][0]+=v,val[x][1]+=vv;
if(l==r){return ;}
int mid=(l+r)>>1;
if(pos<=mid)update(ls[x],ls[y],l,mid,pos,v,vv);
else update(rs[x],rs[y],mid+1,r,pos,v,vv);
}
ll ask(int x,int y,int l,int r,int ql,int qr,int op){
if(ql<=l and r<=qr)return val[y][op]-val[x][op];
int mid=l+r>>1;
ll tem=0;
if(ql<=mid)tem+=ask(ls[x],ls[y],l,mid,ql,qr,op);
if(qr>mid)tem+=ask(rs[x],rs[y],mid+1,r,ql,qr,op);
return tem;
}
signed main() {
#ifdef local
freopen("input2.txt","r",stdin);
#endif // local
int n=rd();
for(int i=1;i<=n;i++){
int x1=rd(),x2=rd(),y1=rd(),a=rd(),b=rd(),y2=rd();
rt[i]=rt[i-1];
update(rt[i],rt[i],0,maxn-3,x1+1,a,b);
update(rt[i],rt[i],0,maxn-3,x2+1,-a,-b);
update(rt[i],rt[i],0,maxn-3,0,0,y1);
update(rt[i],rt[i],0,maxn-3,x1+1,0,-y1);
update(rt[i],rt[i],0,maxn-3,x2+1,0,y2);
}
ll las=0;
int q;
cin>>q;
while(q--){
ll l,r,x;
cin>>l>>r>>x;
x=((ll)x+las)%mo;
ll k=ask(rt[l-1],rt[r],0,maxn-3,0,min((ll)maxn-3,x),0);
ll b=ask(rt[l-1],rt[r],0,maxn-3,0,min((ll)maxn-3,x),1);
las=k*x+b;
cout<<las<<en;
}
}