HDU_2056——相交矩形的面积
5.00 5.00 13.00 13.00 4.00 4.00 12.50 12.50
56.25
#include <cstdio>
double max(double a,double b)
{
return (a>b)?a:b;
}
double min(double a,double b)
{
return (a<b)?a:b;
}
void fun(double &a,double &b)
{
double t;
t=a;a=b;b=t;
}
int main()
{
double x1,y1,x2,y2,x3,y3,x4,y4;
while(~scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4))
{
//规范对角线坐标,对角线是从左下到右上,
if(x1>x2) fun(x1,x2);
if(y1>y2) fun(y1,y2);
if(x3>x4) fun(x3,x4);
if(y3>y4) fun(y3,y4); //如果条件不能构成相交矩阵
if(x1>=x4 || x2<=x3 || y1>=y4 || y2<=y3)
{
printf("%.2lf\n",);
}
else
{
//构造相交矩阵的对角线坐标(x1,y1),(x2,y2)
//相交矩形的对角线坐标能够确定
x1=max(x1,x3);
y1=max(y1,y3);
x2=min(x2,x4);
y2=min(y2,y4);
printf("%.2lf\n",(x2-x1)*(y2-y1));
}
}
return ;
}
HDU_2056——相交矩形的面积的更多相关文章
- TZOJ 2392 Bounding box(正n边形三点求最小矩形覆盖面积)
描述 The Archeologists of the Current Millenium (ACM) now and then discover ancient artifacts located ...
- PHP图形计算器(计算三角形矩形周长面积)
运用PHP面向对象的知识设计一个图形计算器,同时也运用到了抽象类知识,这个计算器可以计算三角形的周长和面积以及矩形的周长和面积.本图形计算器有4个页面:1.PHP图形计算器主页index.php; ...
- Codeforces Round #524 (Div. 2) C. Masha and two friends 几何:判断矩形是否相交以及相交矩形坐标
题意 :给出一个初始的黑白相间的棋盘 有两个人 第一个人先用白色染一块矩形区域 第二个人再用黑色染一块矩形区域 问最后黑白格子各有多少个 思路:这题的关键在于求相交的矩形区间 给出一个矩形的左下和 ...
- HDU1255 扫描线 矩形交面积 离散化
覆盖的面积 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- 一条长为L的绳子,一面靠墙,另外三边组成矩形,问此矩形最大面积能是多少?
靠墙的两边设为x,墙的对边设为y,有2x+y=L; 则y=L-2x, 矩形面积函数为xy=x(L-2x)=-2x2+xL,即f(x)=-2x2+xL 这时就是求二次函数的极值问题了. 按二次函数y=a ...
- maximal-rectangle——找出最大矩形的面积
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and ...
- HDU1255 覆盖的面积 —— 求矩形交面积 线段树 + 扫描线 + 离散化
题目链接:https://vjudge.net/problem/HDU-1255 给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. Input输入数据的第一行是一个正整数T(1<= ...
- Python 实现两个矩形重合面积
计算两个矩形的重合面积 import math x1, y1, x2, y2 = input().split(" ") x1, y1, x2, y2=int(x1), int(y1 ...
- Objectarx 相交矩形求并集 面域转多段线
测试结果: 主要思路:拾取一个点作为矩形的插入点,分别以该点进行两次jig操作,就能得到白色的两个相交的polyline,之后需要变成红色的封闭多段线.做法就是:求出两个白色矩形的面域,然后通过boo ...
随机推荐
- LeetCode——Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- asp.net总结(一)
前言 asp.net的视频不是很多,但是中间由于毕业论文等一些事情.花的时间比较长,知识所以整体上学习的也不是很连贯 打算在总结的时候来复习一下这些知识.只能是大概的来了解asp.net到底有哪些东西 ...
- [Angular 2] Mapping Streams to Values to Affect State
While you have multiple streams flowing into your scan operator, you'll need to map each stream to t ...
- [React] Radium: Updating Button Styles via Props
In a CSS library like Bootstrap we can set a button's style to be "primary" or "secon ...
- cas 官方文档
1. 架构 http://jasig.github.io/cas/4.0.0/planning/Architecture.html System Components The CAS server a ...
- Linux 基础入门----推荐课程
Linux 基础入门课程:https://www.shiyanlou.com/courses/1 很好的一门Linux基础课,精炼.简洁!推荐! 课程内容: 第1节 Linux 系统简介 https: ...
- 人工智能2:智能Agent
一.Agent基本定义 基于理性行为的Agent是本书人工智能方法的核心.Agent由传感器.执行器两个重要元件组成,具有与环境交互的能力,其能力是通过分析感知序列,经过Agent函数映射到相应的行动 ...
- Windows Server 2008 R2 搭建FTP服务
一.安装ftp服务 1.在服务管理器"角色"右键单击"添加角色". 2.下一步. 3.勾选"Web 服务器(IIS)",下一步. 4.勾选 ...
- 95秀-PullToRefreshListView 示例
正在加载.暂无数据页面 public class RefreshGuideTool { private RelativeLayout rl_loading_guide;//整个View ...
- Design Pattern —— Prototype /Template Method/Iterator/Composite/Bridge
Prototype /Template Method/Iterator/Composite/Bridge 为什么把这五种设计模式放一起呢,没什么太高大上的原因,就是因为这五种模式JAVA开发最基本的特 ...