2015北京区域赛 Mysterious Antiques in Sackler Museum 几何基础+思维
生活随笔
收集整理的這篇文章主要介紹了
2015北京区域赛 Mysterious Antiques in Sackler Museum 几何基础+思维
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題意是,選出三個,看看是否可以湊成一個新的矩形。
#include<bits/stdc++.h> using namespace std; struct node { int cnt[2]; }a[5]; bool Check(node x, node y, node z) { for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) for(int k = 0; k < 2; k++) if(x.cnt[!i] == y.cnt[!j] && x.cnt[i] + y.cnt[j] == z.cnt[k]) //一大兩小 return 1; //小的兩邊之和要等于大的一邊,且兩個小的另外一邊要相等 else if(x.cnt[i] == y.cnt[j] && y.cnt[j] == z.cnt[k]) //三等分 return 1; return 0; } int main() { bool flag; int T; cin >> T; while(T--) { flag = 0; for(int i = 0; i < 4; i++) scanf("%d%d", &a[i].cnt[0], &a[i].cnt[1]); for(int i = 0; i < 4; i++) for(int j = 0; j < 4; j++) for(int k = 0; k < 4; k++) { if(i == j || j == k || i == k) //不取重復的矩形 continue; if(Check(a[i], a[j], a[k])) flag = 1; } if(flag) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }?
轉載于:https://www.cnblogs.com/l609929321/p/7761900.html
總結
以上是生活随笔為你收集整理的2015北京区域赛 Mysterious Antiques in Sackler Museum 几何基础+思维的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言函数指针实验
- 下一篇: 第70天:jQuery基本选择器(一)