http://blog.csdn.net/dongdongzhang_/article/details/8866470
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
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]);
}
}
}