5D - Rectangles
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的更多相关文章
- 三维模型2.5D轮廓提取及遮挡部分的剔除
轮廓提取相对容易,只需在2.5D渲染视角下,导出模型的顶点坐标以及基于视角的消隐后的三角形面,将三角面投影后合并就可得到轮廓,轮廓坐标基于2.5d图的基准坐标换算就得到.提取轮廓的在我另外一篇文章中有 ...
- 3dmax渲染插件,生成2.5d瓦片
基于3dmax2013的2.5d渲染插件,demo版,需要的和感兴趣的可以试用,这是百度网盘地址:http://pan.baidu.com/s/1c0mYY7e 插件主要功能,按层级对3dmax场景进 ...
- poj-1314 Finding Rectangles
题目地址: http://poj.org/problem?id=1314 题意: 给出一串的点,有些点可以构成正方形,请按照字符排序输出. 因为这道题的用处很大, 最近接触的cv 中的Rectangl ...
- [ACM_暴力][ACM_几何] ZOJ 1426 Counting Rectangles (水平竖直线段组成的矩形个数,暴力)
Description We are given a figure consisting of only horizontal and vertical line segments. Our goal ...
- 该如何认识ZBrush中的2.5D绘画
ZBrush不仅对3D行业进行了改革.让艺术家感到无约束自由创作的3D设计,同时它还是一个强大的绘画程序!基于强大的Pixol功能,ZBrush®将数字绘画提升到一个新的层次.如下图所示,插画功能主要 ...
- codeforces 713B B. Searching Rectangles(二分)
题目链接: B. Searching Rectangles time limit per test 1 second memory limit per test 256 megabytes input ...
- White Rectangles[HDU1510]
White Rectangles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Java基础之在窗口中绘图——绘制直线和矩形(Sketcher 2 drawing lines and rectangles)
控制台程序. import javax.swing.JComponent; import java.util.*; import java.awt.*; import java.awt.geom.*; ...
- Counting Rectangles
Counting Rectangles Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1043 Accepted: 546 De ...
随机推荐
- servlet 验证码生成
servlet package com.htpo.net; import java.awt.Color;import java.awt.Font;import java.awt.Graphics2D; ...
- SAP 表类型
最近看了一下ABAP的表类型相关知识,做一个自己的分析总结. ABAP的表类型似乎我感觉只应该有2种,而不是大家说的3种. 从数据存储的原理上来看的.下面我做一个分析. 一般情况下,我们都说ABAP中 ...
- 八、AbstractFactory 抽象工厂模式
设计原理: 代码清单: 抽象 Factory : public abstract class Factory { public static Factory getFactory(String cla ...
- Linux 设置Redis开机启动
Debian 也就是Ubun16.04 亲测可用 http://www.tuicool.com/articles/UR73ieq Centos7.0 http://blog.csdn.net/alex ...
- java集合: LinkedList源码浅析
LinkedList 数据结构是双向链表,插入删除比较方便.LinkedList 是线程不安全的,允许元素为null . 构造函数: 构造函数是空的. /** * Constructs an emp ...
- Dedecms织梦内容页获取当前页面顶级栏目名称方法
Dedecms织梦做站的时候,需要在当前页面调用顶级栏目名称的时候,织梦默认{dede:field name='typename' /} 可以获取当前栏目页上一级栏目的名称,而不是当前栏目顶级栏目名称 ...
- zabbix 自定义监控 排除带报错提示
UserParameter=lq_data_sqoop,/usr/local/bin/sqoop.sh 2>/dev/null |awk '{print $2}' 注意:2>/dev/n ...
- 查看linux发行版版本
可以通过查看/etc/issue文件查看发行版版本号,不论系统是redhat\suse\debian
- CentOS rpm
rpm命令是RPM软件包的管理工具.rpm原本是Red Hat Linux发行版专门用来管理Linux各项套件的程序,由于它遵循GPL规则且功能强大方便,因而广受欢迎.逐渐受到其他发行版的采用.RPM ...
- python if __name__ == 'main' 的作用和原理()
相信初学者在学习Python的过程中,不可避免的总会遇到 if __name__ == 'main'语句,虽然一直知道它的作用,但是可能一直比较模糊,今天菜鸟分析就与大家一起举例说说我的理解. 举个例 ...