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. ANg-别人家的笔记

    http://blog.csdn.net/scruelt/article/details/78997697 https://github.com/fengdu78/Coursera-ML-Andrew ...

  2. JavaScript中的构造函数 renturn

    javascript中构造函数是不需要有返回值的,但是如果其中添加了 return 语句结果会如何呢: 看如下代码: 示例1. var Calculator = function () { retur ...

  3. 吴裕雄 oracle 存储过程

  4. hibernate ID

            一:主键生成策略大体分类: 1:hibernate 负责对主键ID赋值  2:应用程序自己为主键ID赋值(不推荐使用) 3:底层数据库为主键ID赋值         二:具体用法    ...

  5. 面试真题--------spring源码解析AOP

    接着上一章对IOC的理解之后,再看看AOP的底层是如何工作的. 1.实现AOP的过程    首先我们要明白,Spring中实现AOP,就是生成一个代理,然后在使用的时候调用代理. 1.1 创建代理工厂 ...

  6. SAP FI模块常用事务代码

    F.52 G/L: Acct Bal.Interest Calculation 总帐:计算科目余额利息 F-06       Post Incoming Payments 收款记帐 F-07      ...

  7. mongodb副本集的从库永久性设置setSlaveOk

    今天在生产环境下面搭了一个mongo的副本集,但开发那边要求副本集读写分离. 坑爹的是每次上副本集的时候都要设置db.getMongo().setSlaveOk()才能访问数据.感觉很是苦逼. 后来开 ...

  8. idea 修改 使用的git账号

    打开控制面板-->用户账户-->凭证管理器 如下图点击进入,删除原有的账号 当在idea中再提交或下载代码时,就会弹出如下提示框: 重新输入你自己的账号就可以了.

  9. 设置https以及http转https的问题

    公司用的是阿里云服务器win2008server r2 ,环境是phpwamp,出现许多问题.2018-11-12 一 设置https 1.设置httpd.ini 取消以下三个配置的# LoadMod ...

  10. ceph 文件系统(cephfs) -- 初体验

    一.介绍: ceph MDS 是元数据服务器,只有ceph 文件系统(cephFS)才会需要. cephFS 在RADOS 层之上 提供一个兼容POSIX 的文件系统.他是用MDS 作为守护进程,负责 ...