洛谷 P2084 进制转换
题目描述
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.
输入输出样例
说明
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(,min(p.x2,q.x2)-max(p.x1,q.x1));
int y_overlap=max(,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);
}
洛谷 P2084 进制转换的更多相关文章
- 洛谷P2084 进制转换
		题目背景 无 题目描述 今天小明学会了进制转换,比如(10101)2 ,那么它的十进制表示的式子就是 : 1*2^4+0*2^3+1*2^2+0*2^1+1*2^0, 那么请你编程实现,将一个M进制的 ... 
- 洛谷P1017 进制转换
		洛谷P1017 进制转换 题目描述 我们可以用这样的方式来表示一个十进制数: 将每个阿拉伯数字乘以一个以该数字所处位置的(值减1)为指数,以10为底数的幂之和的形式.例如:123可表示为 \(1*10 ... 
- 洛谷p1017 进制转换(2000noip提高组)
		洛谷P1017 进制转换 题意分析 给出一个数n,要求用负R进制显示. n∈[-32768,32767].R ∈[-20,-2] 考察的是负进制数的转换,需要理解短除法. 看到这道题的时候,我是比较蒙 ... 
- 洛谷——P1017 进制转换
		P1017 进制转换 题目描述 我们可以用这样的方式来表示一个十进制数: 将每个阿拉伯数字乘以一个以该数字所处位置的(值减1)为指数,以10为底数的幂之和的形式.例如:123可表示为 1\times ... 
- 洛谷——P1143 进制转换
		P1143 进制转换 题目描述 请你编一程序实现两种不同进制之间的数据转换. 输入输出格式 输入格式: 输入数据共有三行,第一行是一个正整数,表示需要转换的数的进制n(2≤n≤16),第二行是一个n进 ... 
- 洛谷P1143 进制转换
		题目描述 请你编一程序实现两种不同进制之间的数据转换. 输入输出格式 输入格式: 输入数据共有三行,第一行是一个正整数,表示需要转换的数的进制n(2≤n≤16),第二行是一个n进制数,若n>10 ... 
- 洛谷 P1143 进制转换
		P1143 进制转换 题目描述 请你编一程序实现两种不同进制之间的数据转换. 输入输出格式 输入格式: 输入数据共有三行,第一行是一个正整数,表示需要转换的数的进制n(2≤n≤16),第二行是一个n进 ... 
- 集训作业 洛谷P1017 进制转换
		这个题的题目真的太恶心了. 重点是他的题目描述和他的目标没啥关系. 和最终目的有关系的只有这么一句话:”输出此负进制数及其基数,若此基数超过10,则参照16进制的方法处理.“ 我们通过看这句话可以发现 ... 
- 洛谷 P1017 进制转换
		推荐洛谷 题目描述 我们可以用这样的方式来表示一个十进制数: 将每个阿拉伯数字乘以一个以该数字所处位置的(值减1)为指数,以10为底数的幂之和的形式.例如:123可表示为 1*10^2+2*10^1+ ... 
随机推荐
- Linux特殊符号及基础正则表达式
			第1章 特殊符号 1.1 引号系列 1.1.1 单引号 所见即所得 单引号里面的内容会原封不动的输出 [root@oldboyedu50-lnb ~]# echo 'oldboy $LANG $PS ... 
- [Swift通天遁地]七、数据与安全-(16)检测Apple设备是否越狱
			★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ... 
- Jsoup爬虫获取公司纳税识别号
			天眼查 /** * 根据公司名称获取统一社会信用代码 * * @author xiaofei.xian 日期:2019年3月20日 上午11:12:41 */ public class GetTaxN ... 
- 最少拦截系统------LCS--------动态规划
			这是一道极好的题,会了这个应该说 最长递增子序列什么的 就有了另外一种思路了 下面附上代码---应该仔细的看一下 那个 if判断 #include<stdio.h> #include ... 
- 322 Coin Change 零钱兑换
			给定不同面额的硬币(coins)和一个总金额(amount).写一个函数来计算可以凑成总金额所需的最少的硬币个数.如果没有任何一种硬币组合方式能组成总金额,返回-1.示例 1:coins = [1, ... 
- Struts2之一 初体验
			Struts2 框架是基于MV模式开发的,它提供了一个核心控制器,用于对所有的请求进行统一处理,这个控制器是由一个名为FilterDispatcher的Servlet过滤器来充当的. 01.需要在we ... 
- ABP初始化
			默认认为你手中已经有abp-zero项目,当前4.6.0 angularJS切换到jquery 运行项目,初始化是跳转到~/App/common/views/layout/layout.cshtml, ... 
- windows环境搭建ui自动化环境
			windows环境安装python虚拟环境 https://www.cnblogs.com/suke99/p/5355894.html https://www.cnblogs.com/jiuyang/ ... 
- DECLARE_DYNAMIC
			DECLARE_DYNAMIC(class_name) DECLARE_DYNCREATE 包含了DECLARE_DYNAMIC的功能,并且可以在运行过程中动态创建对象.如果需要动态创建类对象,需要使 ... 
- CAD在图纸保存的同时,也把基本信息保存了(网页版)
			主要用到函数说明: MxDrawXCustomFunction::Mx_SaveDwgToURLEx 保存DWG文件到服务器上的扩展函数.详细说明如下: 参数 说明 pszServerUrl 服务器网 ... 
