程设作业(合成矩形)
来源:互联网 发布:此何以知 编辑:程序博客网 时间:2024/05/17 10:53
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 input241 1 1 1 1 2 2 241 1 2 2 10 10 20 20sample outputYesNo
答案:
#include<stdio.h>int Findequal(int origin, int *a, int num) { int i, count = 0; for (i = 0; i < num;) { if (origin == a[i]) { count++; i = i + 2; } else if (origin != a[i]) ++i; } return count;}int main(void) { int T, i, j; scanf("%d", &T); while (T--) { int N; scanf("%d", &N); int a[20] = {0}; for (i = 0; i < 2 * N; ++i) scanf("%d", &a[i]); for (i = 0; i < 2 * N; ++i) { if (Findequal(a[i], a, N) >= 3) { printf("Yes\n"); break; } else if (Findequal(a[i], a, N) == 2) { for (j = 0; j < 2 * N; ++j) { if (2 * a[i] == a[j]) { printf("Yes\n"); break; } } break; } } if (i == 2 * N) printf("No\n"); } return 0;}
0 0
- 程设作业(合成矩形)
- 程设作业:模板
- 程设作业:MyString类
- 程设作业(递归判断两个数互质)
- 图片合成-图片合成属性设
- PKU-静态成员作业-程设hw03
- 程设作业:魔兽世界2:装备
- PKU-多态作业-程设hw04
- PKU-MyString类作业-程设hw04-MyString1.cpp(重现)
- PKU-MyInt和HugeInt作业-程设hw03
- PKU-MyString类作业-程设hw04-MyString1.cpp(继承)
- 程设作业:文件操作作业 解题报告&弱弱的代码
- 课后作业之矩形类
- C++作业4.17与4.18合成版
- C++作业4.19与4.20合成版
- 程设作业 2016年12月23日15:52:33
- 合成(Composite)模式
- 合成(Composite)模式
- Android 一些常用工具类的整理
- redis主备集群服务器及自动切换的配置
- 前端开发所需工具
- (6)Java之多线程通信
- 错误Batch update returned unexpected row count from
- 程设作业(合成矩形)
- android studio 快捷键
- 【Linux】图解ARM-Linux的启动全过程
- Oracle 10g导入导出dmp
- Python 学习笔记
- 排序算法之归并排序java实现
- SpringSide4 @RequestBody接受post json对象 (415 Unsupported media type)
- shell正则表达式
- qSort 快速排序源代码