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. C++ 关于 CMFCPropertyGridCtrl 的使用方法 之二 (原创)

    接上一节所讲,这一节咱们重点讲一下CMFCPropertyGridCtrl 所支持的数据表格的建立过程 在上一节中,咱们已经了解到了 CMFCPropertyGridCtrl  是要用到实例函数:Ad ...

  2. VS2012/VS2013配色方案

    VS的配色方案下载地址 http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx 或者 http://studios ...

  3. HBase 1.2.6 完全分布式集群安装部署详细过程

    Apache HBase 是一个高可靠性.高性能.面向列.可伸缩的分布式存储系统,是NoSQL数据库,基于Google Bigtable思想的开源实现,可在廉价的PC Server上搭建大规模结构化存 ...

  4. Centos7.x Docker桥接网络

    基于Centos7.x构建Docker桥接网络, 配置bridge桥接网络可以直接设置网卡配置文件: 自定义桥接网络设置如下: 关掉docker0 ifconfig docker0 down 删除do ...

  5. Mac中安装tensorflow(转)

    当我们开始学习编程的时候,第一件事往往是学习打印"Hello World".就好比编程入门有Hello World,机器学习入门有MNIST.MNIST是一个识别手写数字的程序 M ...

  6. 项目IDEA启动配置

    在所有java启动项中加入 -Djute.maxbuffer=2048000 tomcat 在catalina.bat 中第一行加入 set JAVA_OPTS=-Djute.maxbuffer=20 ...

  7. Object.MemberwiseClone

    [Object.MemberwiseClone] Creates a shallow copy of the current Object. protected object MemberwiseCl ...

  8. ext.js的目录结构的简单解释

    adapter:负责将里面提供第三方底层库(包括Ext自带的底层库)映射为Ext所支持的底层库.    build: 压缩后的ext全部源码(里面分类存放).    docs: API帮助文档.    ...

  9. zabbix 短信报警

    使用的短信平台是云片网,接口请看官网短信接口API文档,有示例 进入server服务器存放脚本的文件夹,默认路径是 [root@test zabbix]# cat zabbix_server.conf ...

  10. Centos7 下的NTP-server(Chorny) 部署及客户端时间同步配置

    一.介绍 1.本博客以 ceph 集群搭建时的NTP-server 为例. 2.hosts # vim /etc/hosts 10.6.32.20    ceph1     (作为时间服务器) 10. ...