http://acm.fzu.edu.cn/problem.php?pid=2300
不用计算几何,要仔细观察,贪心即可。
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
int t;
cin>>t;
while(t--)
{
ll x1,y1,w1,h1;
ll x2,y2,w2,h2;
cin>>x1>>y1>>w1>>h1;
cin>>x2>>y2>>w2>>h2;
ll s=w1*h1+w2*h2;
ll x=max(min(x1+w1,x2+w2)-max(x1,x2),(ll)0);
ll y=max(min(y1+h1,y2+h2)-max(y1,y2),(ll)0);
ll ans=x*y;
s-=ans;
printf("%.2lf\n",1.0*ans/s);
}
return 0;
}