洛谷 P2084 进制转换

P4122 [USACO17DEC]Blocked Billboard

题目描述

During long milking sessions, Bessie the cow likes to stare out the window of her barn at two huge rectangular billboards across the street advertising "Farmer Alex's Amazingly Appetizing Alfalfa" and "Farmer Greg's Great Grain". Pictures of these two cow feed products on the billboards look much tastier to Bessie than the grass from her farm.

One day, as Bessie is staring out the window, she is alarmed to see a huge rectangular truck parking across the street. The side of the truck has an advertisement for "Farmer Smith's Superb Steaks", which Bessie doesn't quite understand, but she is mostly concerned about the truck potentially blocking the view of her two favorite billboards.

Given the locations of the two billboards and the location of the truck, please calculate the total combined area of both billboards that is still visible. It is possible that the truck obscures neither, both, or only one of the billboards.

在平面直角坐标系中,有两个矩形(保证不相交),然后给出第三个矩形,求这两个矩形没有被第三个矩形遮住的部分的面积。

输入输出格式

输入格式:

 

The first line of input contains four space-separated integers: x1 y1 x2 y2, where (x1,y1) and (x2,y2) are the coordinates of the lower-left and upper-right corners of the first billboard in Bessie's 2D field of view. The next line contains four more integers, similarly specifying the lower-left and upper-right corners of the second billboard. The third and final line of input contains four integers specifying the lower-left and upper-right corners of the truck. All coordinates are in the range -1000 to +1000. The two billboards are guaranteed not to have any positive area of overlap between themselves.

题目给出三个坐标,分别表示三个矩形的左下、右上坐标

 

输出格式:

 

Please output the total combined area of both billboards that remains visible.

 

输入输出样例

输入样例#1: 复制
1 2 3 5
6 0 10 4
2 1 8 3
输出样例#1: 复制
17

说明

Here, 5 units of area from the first billboard and 12 units of area from the second billboard remain visible.

Problem credits: Brian Dean

思路:模拟即可。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
struct nond{ int x1,y1,x2,y2; };
int area(nond r){return (r.x2-r.x1)*(r.y2-r.y1);
}
int intersect_area(nond p,nond q){int x_overlap=max(0,min(p.x2,q.x2)-max(p.x1,q.x1));int y_overlap=max(0,min(p.y2,q.y2)-max(p.y1,q.y1));return x_overlap*y_overlap;
}
int main(){nond a,b,t;cin>>a.x1>>a.y1>>a.x2>>a.y2;cin>>b.x1>>b.y1>>b.x2>>b.y2;cin>>t.x1>>t.y1>>t.x2>>t.y2;cout<<area(a)+area(b)-intersect_area(a,t)-intersect_area(b,t);
}

 

转载于:https://www.cnblogs.com/cangT-Tlan/p/8831679.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/466154.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

三极管构成的电流负反馈放大器

▌1.题目设计一个有三极管构成的电流负反馈放大器&#xff0c;放大倍数不小于100倍&#xff0c;集电极最大电流不超过20mA&#xff0c;当负载由1000欧姆变10欧姆时&#xff0c;要求输出电流的波动幅度小于5%。▌2.项目总体功能图▌3.测试条件频率为500HZ、幅度为5mv的正弦波。▌…

C++ —— C++运算符与表达式

C ——运算符与表达式 1、关系运算符及其优先级 在&#xff23;语言中有6种关系运算符&#xff1a;<,<,>,>,,! 在六个关系运算符中&#xff0c;<&#xff0c;<&#xff0c;>&#xff0c;>的优先级相同&#xff0c;和!的优先级相同&#xff0c;<&a…

lzg_ad:FBWF配置详解

在安装好Windows XP Embedded FP2007及以后版本的开发工具后&#xff0c;我们就可以在我们的XPE操作系统镜像中添加FBWF功能了。我们可以在目标设计器中配置FBWF&#xff0c;也就是在构建XPE镜像文件前配置好FBWF&#xff0c;也可以在运行时镜像中配置FBWF。本文将详细介绍这两…

耦合,到底是什么!?

在电路中,将前级电路(信号源)的能量递至后级电路(负载)称为耦合&#xff0c;常见的耦合介质有导线、电容器&#xff0c;变压器、光电耦合器&#xff0c;电子电路&#xff0c;根据不同耦合介质常见有以下耦合方式&#xff0c;这几种耦合方式&#xff0c;各有特点,在不同哪种比较…

hibernate中*.hbm.xml配置文件的各种映射关系配置方法(多对一,多对多)

多对一&#xff1a; 多个用户对应一个部门&#xff0c;是多对一的关系&#xff0c;要在多方配&#xff0c;即在用户的hbm.xml文件中配 <many-to-one name"department" class"Department" column"department_Id" />name"department&qu…

MySQL学习笔记(二)—— MySQL的安装

MySQL可通过直接执行已编译版本安装&#xff0c;这个很简单&#xff0c;无须赘述&#xff0c;有时候&#xff0c;可能需要在安装时进行配置和编译&#xff0c;下面讨论一下相关的配置选项&#xff1a;1&#xff09; 配置的优先级配置选项的优先级如下&#xff1a;命令行、配置…

C++ —— C++三大分支结构(顺序、选择、循环)

C ——三大结构&#xff08;顺序、选择、循环&#xff09; 一、顺序结构的几种常用语句 1、声明语句 程序中所有由程序员给出的名字标识符&#xff0c;包括变量、常量、对象、类、类型、函数、参数等都要在使用前进行说明或定义。一般地&#xff0c;程序中的说明语句并不单纯说…

三极管的“非教科书式”解析,什么正偏、反偏都统统滚蛋!

什么正偏&#xff0c;反偏都统统滚蛋&#xff01;&#xff01;&#xff01;❤三极管有三个工作状态&#xff1b;截止、放大、饱和&#xff1b;放大状态很有学问也很复杂&#xff0c;多用于集成芯片&#xff0c;比如运放&#xff0c;现在不讨论&#xff1b;其实对信号的放大我们…

CListBox用法总结

CListBox用法总结 用法 属性Style Selection Single — 单选 Multiple — 多选(LBS_MULTIPLESEL) None — 不可选(LBS_NOSEL) Sort 对应Style: LBS_SORT Insert Item int AddString(LPCTSTR lpszItem); int InsertString(int nIndex, LPCTSTR lpszItem); Delete Item int Del…

django 模板继承与重写

1、模板的继承一般用在别人给我们做好的HTML页面&#xff0c;当我们发现有很多的页面都具有相同的部分&#xff0c;这会我们应该考虑怎么能把他们相同的部分给提取出来&#xff0c;提取出来的部分我们作为一个单独的HTML文件叫做base.html&#xff0c;其余不同的部分我们在base…

SUN平台,光纤共享存储互斥失败导致的数据灾难恢复

作者&#xff1a;张宇&#xff0c;北亚数据恢复中心&#xff0c;转载请联系作者&#xff0c;如果实在不想联系作者&#xff0c;至少请保留版权&#xff0c;谢谢。[数据恢复故障描述]两台SPARC SOLARIS系统通过光纤交换机共享同一存储&#xff0c;本意是作为CLUSTER使用&#xf…

C++ —— C++类

C ——类 1、类 类是具有相同属性和行为的一组对象的集合,它为属于该类的全部对象提供了统一的抽象描述,其内部包括属性和行为两个主要部分。 class Clock { public:void SetTime(int new_hour, int new_minute,int new_second);void ShowTime(); private:int hour, minute, se…

一行代码还能这么秀

老早就想写这篇文章了&#xff0c;因为我经常用用这个方法来装逼&#xff0c;今天终于要把这个装逼方法分享给大家了。我从来不会告诉别人我自己的微信公众号关注早就已经超过40万了。看下面的截图这张截图建议大家保存下&#xff0c;如果遇到不公的事情&#xff0c;你就跟他说…

原来你是这样的Promise

1. Promise简介 promise是异步编程的一种解决方案&#xff0c;它出现的初衷是为了解决回调地狱的问题。 打个比方&#xff0c;我需要&#xff1a; --(延迟1s)--> 输出1 --(延迟2s)--> 输出2 --(延迟3s)--> 输出3 通常写法&#xff1a; setTimeout(()> {console.log…

VS2015 vc++ 项目出现new.h找不到的错误

安装完 VS2015 后&#xff0c;直接新建项目->win32控制台->运行&#xff0c;结果报错&#xff01;"无法打开包括文件: “stdio.h”: No such file or directory”"lnk1104:无法打开文件 ucrtd.lib ”奇了怪了&#xff0c;stdio.h 和 ucrtd.lib 都是 VS 自带的头…

C#——image与byte数组的转换

image to byte[] MemoryStream msnew MemoryStream(); image.Save(ms,System.Drawing.Imaging.ImageFormat.Gif ); byte[] imagedatams.GetBuffer (); byte[] to imageMemoryStream ms new MemoryStream(imagedata);img Drawing.Image.FromStream(ms);转载于:https://www.cnb…

Linux Select

Linux Select 在Linux中&#xff0c;我们可以使用select函数实现I/O端口的复用&#xff0c;传递给 select函数的参数会告诉内核&#xff1a; •我们所关心的文件描述符 •对每个描述符&#xff0c;我们所关心的状态。(我们是要想从一个文件描述符中读或者写&#xff0c;还…

搞懂图像二值化算法

传统的机器视觉通常包括两个步骤&#xff1a;预处理和物体检测。而沟通二者的桥梁则是图像分割&#xff08;Image Segmentation&#xff09;[1]。图像分割通过简化或改变图像的表示形式&#xff0c;使得图像更易于分析。举个例子&#xff0c;食品加工厂新进了一批肉鸡&#xff…

vs2015无法打开包括文件:“winapifamily.h”

老项目是vs2003下的项目。升级vs2015后&#xff0c;调试运行报错 C:\Program Files (x86)\Windows Kits\8.0\Include\um\winsdkver.h(21): fatal error C1083: 无法打开包括文件:“winapifamily.h”: No such file or directory 在项目包含目录中包含了这个Windows Kits\8.0\…

JavaWeb无限级分销结构分析

在现实生活中我们经常遇到由推荐人注册&#xff0c;比如一个购物平台,用户A推荐用户B注册&#xff0c;那当B购买商品成功时&#xff0c;用户A就会拿到相应的提成。只要是用户A推荐的用户购买商品成功后&#xff0c;A用户都会拿到提成。 当用户B推荐了用户C&#xff0c;那当用户…