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

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

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.00
5.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50

Sample Output

1.00
56.25 // 没考虑无相交区域
 #include<stdio.h>
int main()
{
double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t;
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
{
if(x1>x2)
{ t=x2; x2=x1; x1=t; }
if(y1>y2)
{ t=y2; y2=y1; y1=t; }
if(x3>x4)
{ t=x4; x4=x3; x3=t; }
if(y3>y4)
{ t=y4; y4=y3; y3=t; }
a=x1-x4>x3-x2?x1-x4:x3-x2;
b=y1-y4>y3-y2?y1-y4:y3-y2;
printf("%.2f\n", a*b);
}
return ;
}

WA

// 还是错得离谱 感觉没有智商T^T
 #include<stdio.h>
int main()
{
double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t;
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
{
if(x1>x2)
{ t=x2; x2=x1; x1=t; }
if(y1>y2)
{ t=y2; y2=y1; y1=t; }
if(x3>x4)
{ t=x4; x4=x3; x3=t; }
if(y3>y4)
{ t=y4; y4=y3; y3=t; }
a=x1-x4>x3-x2?x1-x4:x3-x2;
b=y1-y4>y3-y2?y1-y4:y3-y2;
if(a>=||b>=) printf("0.00\n");
else printf("%.2f\n", a*b);
}
return ;
}

WA*2

// 
 #include<stdio.h>
int main()
{
double x1,y1, x2,y2, x3,y3, x4,y4, a,b, t;
while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)
{
if(x1>x2)
{ t=x2; x2=x1; x1=t; }
if(y1>y2)
{ t=y2; y2=y1; y1=t; }
if(x3>x4)
{ t=x4; x4=x3; x3=t; }
if(y3>y4)
{ t=y4; y4=y3; y3=t; }
a=(x2<x4?x2:x4)-(x1>x3?x1:x3);
b=(y2<y4?y2:y4)-(y1>y3?y1:y3);
if(a<||b<) printf("0.00\n");
else printf("%.2f\n", a*b);
}
return ;
}

AC

5D - Rectangles的更多相关文章

  1. 三维模型2.5D轮廓提取及遮挡部分的剔除

    轮廓提取相对容易,只需在2.5D渲染视角下,导出模型的顶点坐标以及基于视角的消隐后的三角形面,将三角面投影后合并就可得到轮廓,轮廓坐标基于2.5d图的基准坐标换算就得到.提取轮廓的在我另外一篇文章中有 ...

  2. 3dmax渲染插件,生成2.5d瓦片

    基于3dmax2013的2.5d渲染插件,demo版,需要的和感兴趣的可以试用,这是百度网盘地址:http://pan.baidu.com/s/1c0mYY7e 插件主要功能,按层级对3dmax场景进 ...

  3. poj-1314 Finding Rectangles

    题目地址: http://poj.org/problem?id=1314 题意: 给出一串的点,有些点可以构成正方形,请按照字符排序输出. 因为这道题的用处很大, 最近接触的cv 中的Rectangl ...

  4. [ACM_暴力][ACM_几何] ZOJ 1426 Counting Rectangles (水平竖直线段组成的矩形个数,暴力)

    Description We are given a figure consisting of only horizontal and vertical line segments. Our goal ...

  5. 该如何认识ZBrush中的2.5D绘画

    ZBrush不仅对3D行业进行了改革.让艺术家感到无约束自由创作的3D设计,同时它还是一个强大的绘画程序!基于强大的Pixol功能,ZBrush®将数字绘画提升到一个新的层次.如下图所示,插画功能主要 ...

  6. codeforces 713B B. Searching Rectangles(二分)

    题目链接: B. Searching Rectangles time limit per test 1 second memory limit per test 256 megabytes input ...

  7. White Rectangles[HDU1510]

    White Rectangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. Java基础之在窗口中绘图——绘制直线和矩形(Sketcher 2 drawing lines and rectangles)

    控制台程序. import javax.swing.JComponent; import java.util.*; import java.awt.*; import java.awt.geom.*; ...

  9. Counting Rectangles

    Counting Rectangles Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1043 Accepted: 546 De ...

随机推荐

  1. ArcGIS案例学习笔记-CAD数据自动拓扑检查

    ArcGIS案例学习笔记-CAD数据自动拓扑检查 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 功能:针对CAD数据,自动进行拓扑检查 优点:类别:地理建模项目实例 ...

  2. 创建springboot项目步骤

    步骤:

  3. 局部变量and全局变量

    局部变量 <1>什么是局部变量 如下图所示: <2>小总结 局部变量,就是在函数内部定义的变量 不同的函数,可以定义相同的名字的局部变量,但是各用个的不会产生影响 局部变量的作 ...

  4. SAP RFC函数

    RFC 接口 RFC是对一个函数模块的调用,但是调用者的系统与被调函数所在的系统是不一样的. RFC也可以在系统内被调用,但是通常调用和被调用是在不同的系统中的. 在sap系统中,远程调用的能力是有R ...

  5. js模板引擎用法

    JavaScript模板引擎Template.js使用详解 作者:A_山水子农 字体:[增加 减小] 类型:转载 时间:2016-12-15我要评论 这篇文章主要为大家详细介绍了JavaScript模 ...

  6. 初识Elasticsearch,bulk 操作的遇到的那些事

    bulk api可以在单个请求中一次执行多个文档的 create . index . update 或 delete 操作 批量操作的行为(action)必须是以下几种: 行为 解释 create 当 ...

  7. 05_ssm基础(一)之mybatis简单使用

    01.mybatis使用引导与准备 1.ssm框架 指: sping+springMVC+mybatis 2.学习mybatis前准备web标准项目结构 model中的Ticket代码如下: pack ...

  8. 什么是webFlux

    什么是webFlux 左侧是传统的基于Servlet的Spring Web MVC框架,右侧是5.0版本新引入的基于Reactive Streams的Spring WebFlux框架,从上到下依次是R ...

  9. 多线程 ThreadLocal

    要了解ThreadLocal,首先搞清楚ThreadLocal 是什么?是用来解决什么问题的? ThreadLocal 是线程的局部变量, 是每一个线程所单独持有的,其他线程不能对其进行访问, 通常是 ...

  10. hdoj1005(循环,找规律)

    Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1 ...