http://blog.csdn.net/dongdongzhang_/article/details/8866470
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> #include <io
Stream> using namespace std;
#define LL __int64 #define N 200005 ll A[n],b[n],c[n];
ll D,e,f,g;
void Add (ll s,ll t,ll a,ll b,ll C) {a[s]+=a;
A[t+1]-=a;
B[s]+=b;
B[t+1]-=b;
C[s]+=c;
C[t+1]-=c;
} void Insert (ll x1,ll y1,ll x2,ll y2) {ll t1=max (x1,y1);
ll T2=min (X2,Y2);
ll T3=max (X2,Y2);
if (T2>T1) Add (t1+1,t2,1,-(x1+y1), x1*y1);
else t2=t1;
if (y2>x2) Add (t2+1,t3,0,x2-x1,-y1* (x2-x1));
else if (x2>y2) Add (t2+1,t3,0,y2-y1,-x1* (y2-y1));
Add (t3+1,200000,0,0, (x2-x1) * (y2-y1));
} int main () {int t;
cin>>t;
while (t--) {int n;
cin>>n;
memset (A,0,sizeof (a));
Memset (b,0,sizeof (b));
Memset (C,0,sizeof (c));
while (n--) {scanf ("%i64d%i64d%i64d%i64d", &d,&e,&f,&g);
Insert (D,E,F,G);
} int i;
for (i=1;i<=200001;i++) {a[i]+=a[i-1];
B[I]+=B[I-1];
C[I]+=C[I-1];
} int k; Cin>>K
while (k--) {ll h;
scanf ("%i64d", &h);
printf ("%i64d\n", H*h*a[h]+h*b[h]+c[h]); }
}
}