UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形)
Sackler Museum of Art and Archaeology at Peking University is located on a beautiful site near the West Gate of Peking University campus, and its architecture takes the inspiration from buildings that already exist on campus.
The collection of Chinese art and artifacts currently housed in this new museum contains more than 10, 000 objects and spans a period of 280, 000 years, from Paleolithic hominids and stone tool remains to costumes, ceramics and paintings of the present era. The collection, which is used for teaching and research purposes, has been acquired during the past seventy years from diverse sources.
The use of some objects in the museum remains unknown. For example, there are four pieces of rectangular bones which can be dated back to 200, 000 years ago, and no one knows what they were made for. A former NOIer and present ACMer, Mr. Liang in the School of Archaeology and Museology is very interested in those bones, and his tutor told him to use his wildest imagination to guess the usage of them. So, one day, a crazy idea came up to him: were those bones some kind of IQ test tools used by ancient people? Maybe the one who could pick exactly three pieces of those bones to form a larger rectangle was considered smart at that time. So Mr. Liang wanted to write a program to find out how to pass this IQ test imagined by him. Can you also do this?
Input
There are several test cases. The first line of input is an integer T (1 ≤ T ≤ 20), indicating the number of test cases. Each test case is in one line and contains 8 integers describing 4 rectangular bones. Each bone is described by 2 integers indicating its width and height.
All integers in the input are between [1, 1000].
Output
For each test case, if Mr. Liang can form a rectangle using those bones in the way he imagined, please print ‘Yes’. If he can’t, print ‘No’ instead. Please note that the area of the new rectangle he forms must be equal to the total area of the bones he picks.
Sample Input
2
1 1 1 1 1 2 2 2
1 1 2 2 10 10 20 20
Sample Output
Yes
No
题意:有t组数据,每组给定4个长方形的宽和高,问是否能从中任取三个构成一个严格的长方形,严格的长方形指的是长方形内部没有空缺。
题解:从中任取三个,进行判断即可,写成结构体用函数判断可以大幅减少代码量。
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
struct D{
int w,h;
D(int w0=,int h0=) {
w = w0;
h = h0;
}
}data[];
D ll(D a,D b){
if(a.w==b.w) return D(a.w,a.h+b.h);
else if(a.h==b.w) return D(a.h,a.w+b.h);
else if(a.h==b.h) return D(a.h,a.w+b.w);
else if(a.w==b.h) return D(a.w,a.h+b.w);
else return D(,);
}
bool pd(D a,D b,D c){
D tmp;
tmp = ll(a,b);
tmp = ll(tmp,c);
if(tmp.w>) return true;
tmp = ll(a,c);
tmp = ll(tmp,b);
if(tmp.w>) return true;
tmp = ll(b,c);
tmp = ll(tmp,a);
if(tmp.w>) return true;
return false;
}
bool solve() {
if(pd(data[],data[],data[])) return true;
if(pd(data[],data[],data[])) return true;
if(pd(data[],data[],data[])) return true;
if(pd(data[],data[],data[])) return true;
return false;
}
int main() {
int T;
scanf("%d",&T);
while(T--) {
for(int i=;i<;i++) {
scanf("%d%d",&data[i].w,&data[i].h);
}
if(solve()) puts("Yes");
else puts("No");
}
}
UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形)的更多相关文章
- UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)
题意:给定四个矩形,要求从中选出三个,能不能拼成一个矩形. 析:说到这个题,我还坑了队友一次,读题读错了,我直接看的样例,以为是四个能不能组成,然后我们三个就拼命想有什么简便方法,后来没办法了,直接暴 ...
- Mysterious Antiques in Sackler Museum(判断长方形)
题目链接 参考博客Ritchie丶的博客 - UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形) 题意:大概意思就是判断四个矩形能不能 ...
- 【hihocoder1255 Mysterious Antiques in Sackler Museum】构造 枚举
2015北京区域赛现场赛第2题. 题面:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf OJ链接:http://hih ...
- hiho1255 Mysterious Antiques in Sackler Museum
题目链接:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf 题目大意:给你四个矩形,判断是否能取其中任意三个组成一个大矩 ...
- 2015北京区域赛 Mysterious Antiques in Sackler Museum 几何基础+思维
题意是,选出三个,看看是否可以凑成一个新的矩形. #include<bits/stdc++.h> using namespace std; struct node { ]; }a[]; b ...
- 院校-美国:哈佛大学(Harvard University)
ylbtech-院校-美国:哈佛大学(Harvard University) 哈佛大学(Harvard University),简称“哈佛”,坐落于美国马萨诸塞州波士顿都市区剑桥市,是一所享誉世界的私 ...
- CodeForces 596A
Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...
- 简单几何(判断矩形的位置) UVALive 7070 The E-pang Palace(14广州B)
题目传送门 题意:给了一些点,问组成两个不相交的矩形的面积和最大 分析:暴力枚举,先找出可以组成矩形的两点并保存起来(vis数组很好),然后写个函数判断四个点是否在另一个矩形内部.当时没有保存矩形,用 ...
- UVALive 7281 Saint John Festival (凸包+O(logn)判断点在凸多边形内)
Saint John Festival 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/J Description Porto's ...
随机推荐
- BZOJ-1050 旅行comf 并查集+乱搞
好久以前codevs上做过的,拿着改了改.. 1050: [HAOI2006]旅行comf Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2194 S ...
- Springside学习
http://blog.chinaunix.net/uid-122937-id-3935052.html [一]Maven + Eclipse + springside4安装与配置 Maven安装与配 ...
- 洛谷P1134 阶乘问题
题目描述 也许你早就知道阶乘的含义,N阶乘是由1到N相乘而产生,如: 12! = 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 = 479,001, ...
- 初学structs2,结果类型简单示例
一.自定义结果处理类,structs.xml中package节点下加result-types节点,在result-types节点下配置result-type的属性.然后在配置的action中的resu ...
- Java初学(五)
一.成员变量和局部变量区别(成员变量默认为包内访问权限,即使是子类,不在一个包内也无法访问) 1.在类中的位置不同 成员变量:在类中方法外: 局部变量:在方法定义中或者方法声明上 2.在内存中的位置不 ...
- RSA算法小记
学习来源:http://www.cnblogs.com/vamei/p/3480994.html 小记: 一.数学基础: 欧拉Phi函数:Φ(n)=总数(从1到n-1中与n互质的整数) (1)欧拉定理 ...
- TCP/IP协议栈概述
TCP/IP协议栈概述 这篇文章虽然只是很粗浅的介绍了ISO/OSI 网络模型,但确实把握住了关键点,某种意义上,简单回顾一下就可以加深对TCP/IP协议栈的理解. 原作者:阮一峰 链接: http: ...
- CentOS7 最小化安装后启用无线连接网络
1.ip addr 找到自己的无线网接口 (ps:本人的是wlp2s0) 2.ip link set wlp2s0 up 打开无线网的驱动 3.ip link show wlp2s0 查看该网络接口的 ...
- JavaScriptSerializer中日期序列化问题解决方案
JavaScriptSerializer中日期序列化问题解决方案 直接进入主题: class Student { public int age { get; set; } public DateTim ...
- linux 的useradd 命令的p选项
linux 的useradd 命令的p选项 错误用法: #useradd gaojian -p gaojian # ...