UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)
题意:给定四个矩形,要求从中选出三个,能不能拼成一个矩形。
析:说到这个题,我还坑了队友一次,读题读错了,我直接看的样例,以为是四个能不能组成,然后我们三个就拼命想有什么简便方法,后来没办法了,直接暴力。
康神写了6000多B的代码,全是循环和if-else,我们画出五种情况。。。。然而并不是这样,
只要几个if-else就够,因为就3个,两种情况。
代码如下;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
using namespace std ; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int n, m;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
P a[4]; bool judge(int i, int j, int k){
if(a[i].first == a[j].first && a[i].first == a[k].first) return true;
if(a[i].first == a[j].first && a[i].first == a[k].second) return true;
if(a[i].first == a[j].second && a[i].first == a[k].first) return true;
if(a[i].first == a[j].second && a[i].first == a[k].second) return true; if(a[i].second == a[j].first && a[i].second == a[k].first) return true;
if(a[i].second == a[j].first && a[i].second == a[k].second) return true;
if(a[i].second == a[j].second && a[i].second == a[k].first) return true;
if(a[i].second == a[j].second && a[i].second == a[k].second) return true; if(a[i].first == a[j].first + a[k].first && a[j].second == a[k].second) return true;
if(a[i].first == a[j].first + a[k].second && a[j].second == a[k].first) return true;
if(a[i].first == a[j].second + a[k].second && a[j].first == a[k].first) return true;
if(a[i].first == a[j].second + a[k].first && a[j].first == a[k].second) return true; if(a[i].second == a[j].first + a[k].first && a[j].second == a[k].second) return true;
if(a[i].second == a[j].first + a[k].second && a[j].second == a[k].first) return true;
if(a[i].second == a[j].second + a[k].second && a[j].first == a[k].first) return true;
if(a[i].second == a[j].second + a[k].first && a[j].first == a[k].second) return true;
return false;
} int main(){
int T; cin >> T;
while(T--){
for(int i = 0; i < 4; ++i){
scanf("%d %d", &a[i].first, &a[i].second);
}
bool ok = false;
for(int i = 0; i < 4; ++i)
for(int j = 0; j < 4; ++j){
if(i == j) continue;
for(int k = 0; k < 4; ++k){
if(k == i || k == j) continue;
if(judge(i, j, k)) ok = true;
}
}
if(ok) puts("Yes");
else puts("No");
}
return 0;
}
UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)的更多相关文章
- UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形)
Sackler Museum of Art and Archaeology at Peking University is located on a beautiful site near the W ...
- 【hihocoder1255 Mysterious Antiques in Sackler Museum】构造 枚举
2015北京区域赛现场赛第2题. 题面:http://media.hihocoder.com/contests/icpcbeijing2015/problems.pdf OJ链接:http://hih ...
- Mysterious Antiques in Sackler Museum(判断长方形)
题目链接 参考博客Ritchie丶的博客 - UVALive 7267 Mysterious Antiques in Sackler Museum (判断长方形) 题意:大概意思就是判断四个矩形能不能 ...
- 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 ...
- Gym 101194L / UVALive 7908 - World Cup - [三进制状压暴力枚举][2016 EC-Final Problem L]
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...
- 院校-美国:哈佛大学(Harvard University)
ylbtech-院校-美国:哈佛大学(Harvard University) 哈佛大学(Harvard University),简称“哈佛”,坐落于美国马萨诸塞州波士顿都市区剑桥市,是一所享誉世界的私 ...
- UVALive 4123 Glenbow Museum (组合数学)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 易得,当n为奇数或者n<3时,答案为0,否则该序列中必定有(n+4)/2个R ...
- 【暑假】[实用数据结构]UVAlive 4670 Dominating Patterns
UVAlive 4670 Dominating Patterns 题目: Dominating Patterns Time Limit: 3000MS Memory Limit: Unkn ...
随机推荐
- 1160. Network(最小生成树)
1160 算是模版了 没什么限制 结束输出就行了 #include <iostream> #include<cstdio> #include<cstring> #i ...
- dp,px转换
public static int dip2px(Context context, float dpValue) { final float scale = context.getRes ...
- C#将HTML导出Excel
首先这个 不能用ajax 操作,不过 我现在讲的 这个方法和ajax 的效果一样. 你在你需要导出的页面写个方法 function DaoChu () { location.href = " ...
- bzoj1043
每次做计算几何题都要做好久 考虑每个圆对答案的贡献,也就是每个圆被后面圆覆盖还有多少 可以把覆盖当成盖住一段弧度,看最后有多少没被覆盖 这就相当于线段覆盖问题了, 推推公式,算极角然后排序即可 md, ...
- HDU 1695 (莫比乌斯反演) GCD
题意: 从区间[1, b]和[1, d]中分别选一个x, y,使得gcd(x, y) = k, 求满足条件的xy的对数(不区分xy的顺序) 分析: 虽然之前写过一个莫比乌斯反演的总结,可遇到这道题还是 ...
- [Sciter系列] MFC下的Sciter–1.创建工程框架
Sciter SDK中提供的Win32下例程很多,唯独使用很多(对我个人而言)的MFC框架下Sciter程序的构建讲的很少,虽然MFC有这样那样的诟病,但是不可否认的是编写一般的小项目,这仍然是大多数 ...
- zoj 2095 Divisor Summation
和 hdu 1215 一个意思// 只是我 1坑了 1 时应该为0 #include <iostream> #include <math.h> #include <map ...
- 《C++ Primer 4th》读书笔记 第7章-函数
原创文章,转载请注明出处:http://www.cnblogs.com/DayByDay/p/3912413.html
- TCP/IP详解学习笔记(2)-数据链路层
数据链路层有三个目的: 为IP模块发送和 接收IP数据报. 为ARP模块发送ARP请求和接收ARP应答. 为RARP发送RARP请 求和接收RARP应答 ip大家都听说过.至于ARP和RARP,ARP ...
- delphi 编译的时候 把Warning去除的方法
delphi 编译的时候 把Warning去除的方法 在 添加 {$WARNINGS OFF}