2056 Rectangles
来源:互联网 发布:王充 论衡 知乎 编辑:程序博客网 时间:2024/06/06 03:08
Rectangles
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 15358 Accepted Submission(s): 4912
Problem Description
Given two rectangles and the coordinates of two points on the diagonals of each rectangle,you have to calculate the area of the intersected part of two rectangles. its sides are parallel to OX and OY .
Input
Input The first line of input is 8 positive numbers which indicate the coordinates of four points that must be on each diagonal.The 8 numbers are x1,y1,x2,y2,x3,y3,x4,y4.That means the two points on the first rectangle are(x1,y1),(x2,y2);the other two points on the second rectangle are (x3,y3),(x4,y4).
Output
Output For each case output the area of their intersected part in a single line.accurate up to 2 decimal places.
Sample Input
1.00 1.00 3.00 3.00 2.00 2.00 4.00 4.005.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50
Sample Output
1.0056.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;
}
}
0 0
- Rectangles 2056
- 2056 Rectangles
- 2056 Rectangles
- hdu 2056 Rectangles
- HDU 2056 Rectangles
- 杭电 2056 Rectangles
- 2056——Rectangles
- hdu 2056 Rectangles
- HDU 2056 Rectangles
- hdoj.2056 Rectangles 20140729
- HDU 2056 rectangles
- HDU_ACM-2056 Rectangles
- HDU - 2056 Rectangles
- HDU 2056 Rectangles
- HDOJ 2056 Rectangles
- HDU 2056 Rectangles
- HDU 2056 Rectangles
- 杭电2056 Rectangles
- 多种背包(HDU 1059)
- 历程
- 数据结构实验之图论二:基于邻接表的广度优先搜索遍历
- 七周七语言--安装篇
- HDU4099 Revenge of Fibonacci
- 2056 Rectangles
- QA要从RD开始,自我测试
- [Hb-VI] 使用[ bx + si(di) + idata ]更灵活的访问内存
- 带参宏使用
- get an image file with XMLHttpRequest and encode with base64
- 第十三周项目6-体验文件操作:C++文件操作初体验
- 项目二-成绩处理
- leetcode sort-list
- uva-1593 代码对齐