rectangle(暴力求解)
来源:互联网 发布:c语言long占几个字节 编辑:程序博客网 时间:2024/05/21 22:50
Description:
Give you N rectangles.If you can pick exactly three pieces of those rectangles to form a larger rectangle?
input:
There are several testcases.
The first line is an integer T, indicating the number of testcases.
For each testcase:
The first line is a integer N and N is no more than 10.
The second line contains 2*N integers describing N rectangles.Each rectangle is described by 2 integers indicating as width and height.
All these integers in the second line are between [1,10000]
output
If you can do it, print Yes.Otherwise, print No instead.
sample input
2
4
1 1 1 1 1 2 2 2
4
1 1 2 2 10 10 20 20
sample output
Yes
No
#include<stdio.h>int a[110][2][2];int main() { int T, n; int i, j, k, x, y, z; int flag; scanf("%d", &T); while (T--) {//不必使用for循环! scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d%d", &a[i][0][0], &a[i][0][1]); a[i][1][0] = a[i][0][1];//0与1的取反,目的是方便后面的暴力求解 a[i][1][1] = a[i][0][0]; } flag = 0; for (i = 1; i <= n; i++) { for (x = 0; x <= 1; x++) for (j = 1; j <= n; j++) { if (i == j) continue; for (y = 0; y <= 1; y++) for (k = 1; k <= n; k++) { if (i == k || j == k) continue; for (z = 0; z <= 1; z++) { if (a[i][x][0] + a[j][y][0] == a[k][z][0] && a[i][x][1] == a[j][y][1]) flag = 1; if (a[i][x][0] == a[j][y][0] && a[i][x][0] == a[k][z][0]) flag = 1; } } } }//暴力求解! if (flag) { printf("Yes\n"); } else { printf("No\n"); } }}
0 0
- rectangle(暴力求解)
- ***HDU 4429 - Split the Rectangle(LCA'暴力求解)
- hdoj1395(暴力求解)
- poj 2739(暴力求解)
- FZU 2064(暴力求解)
- HDU 4429 Split the Rectangle(暴力)
- 暴力求解
- 暴力求解
- hdu2069Coin Change(暴力求解----动态规划(背包)求解---搜索--)
- 494. Target Sum(暴力求解和二项式求解)
- hdu 1303(Doubles )(暴力求解)
- UVA - 11218 KTV(暴力求解)
- CodeChef WPROB(数组辅助+暴力求解)
- ZOJ 3818 Pretty Poem(暴力求解)
- CSU 1553 Good subsequence(暴力求解)
- uva 1419 Ugly Windows(暴力求解)
- 蓝桥杯--比酒量(暴力求解)
- zzulioj--1870--马拉松后记(暴力求解)
- maven 创建自定义archetype
- iOS开发常用正则表达式
- SSH框架之jar包讲解
- Spring整合mq
- 【Leet Code】229. Majority Element II---Medium
- rectangle(暴力求解)
- 如何同时打开多个Unity软件
- collectd python
- [TagCss]列表元素写法规范
- android 中 topbar 使用
- netstat 命令学习
- net.sf.json.JSONArray & net.sf.json.JSONObject
- 表连接(oralce、mysql、sql server)
- MyBatis动态SQL