Rectangles
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 15358 Accepted Submission(s): 4912
1.00 1.00 3.00 3.00 2.00 2.00 4.00 4.00 5.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50
1.00 56.25
# include <iostream>
# include <algorithm>
# include <iomanip>
using namespace std;
void main()
{
double x1,y1,x2,y2;
double a1,b1,a2,b2;
while(cin>>x1>>y1>>x2>>y2>>a1>>b1>>a2>>b2)
{
if(x1>x2) swap(x1,x2);
if(y1>y2) swap(y1,y2);
if(a1>a2) swap(a1,a2);
if(b1>b2) swap(b1,b2);
double xd=x1>a1?x1:a1;
double yd=y1>b1?y1:b1;
double xu=x2>a2?a2:x2;
double yu=y2>b2?b2:y2;
if(xu<xd || yu<yd)
cout<<"0.00"<<endl;
else
cout<<fixed<<setprecision(2)<<(xu-xd)*(yu-yd)<<endl;
}
}