A11337 | Rectangle Cutting
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Bob has a rectangle of size $a \times b$ . He tries to cut this rectangle into two rectangles with integer sides by making a cut parallel to one of the sides of the original rectangle. Then Bob tries to form some other rectangle from the two resulting rectangles, and he can rotate and move these two rectangles as he wishes.
Note that if two rectangles differ only by a $90^{\circ}$ rotation, they are considered the same. For example, the rectangles $6 \times 4$ and $4 \times 6$ are considered the same.
Thus, from the $2 \times 6$ rectangle, another rectangle can be formed, because it can be cut into two $2 \times 3$ rectangles, and then these two rectangles can be used to form the $4 \times 3$ rectangle, which is different from the $2 \times 6$ rectangle.
However, from the $2 \times 1$ rectangle, another rectangle cannot be formed, because it can only be cut into two rectangles of $1 \times 1$ , and from these, only the $1 \times 2$ and $2 \times 1$ rectangles can be formed, which are considered the same.
Help Bob determine if he can obtain some other rectangle, or if he is just wasting his time.
Note that if two rectangles differ only by a $90^{\circ}$ rotation, they are considered the same. For example, the rectangles $6 \times 4$ and $4 \times 6$ are considered the same.
Thus, from the $2 \times 6$ rectangle, another rectangle can be formed, because it can be cut into two $2 \times 3$ rectangles, and then these two rectangles can be used to form the $4 \times 3$ rectangle, which is different from the $2 \times 6$ rectangle.
However, from the $2 \times 1$ rectangle, another rectangle cannot be formed, because it can only be cut into two rectangles of $1 \times 1$ , and from these, only the $1 \times 2$ and $2 \times 1$ rectangles can be formed, which are considered the same.
Help Bob determine if he can obtain some other rectangle, or if he is just wasting his time.
输入格式
Each test consists of multiple test cases. The first line contains a single integer $t$ ( $1 \leq t \leq 10^4$ ) — the number of test cases. This is followed by the description of the test cases.
The single line of each test case contains two integers $a$ and $b$ ( $1 \le a, b \le 10^9$ ) — the size of Bob's rectangle.
The single line of each test case contains two integers $a$ and $b$ ( $1 \le a, b \le 10^9$ ) — the size of Bob's rectangle.
输出格式
For each test case, output "Yes" if Bob can obtain another rectangle from the $a \times b$ rectangle. Otherwise, output "No".
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive answers.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive answers.
输入输出样例
输入 #1
7 1 1 2 1 2 6 3 2 2 2 2 4 6 3
输出 #1
No No Yes Yes Yes Yes No
In the first test case, the $1 \times 1$ rectangle cannot be cut into two rectangles, so another rectangle cannot be obtained from it.
In the fourth test case, the $3 \times 2$ rectangle can be cut into two $3 \times 1$ rectangles, and from these, the $1 \times 6$ rectangle can be formed.
In the fifth test case, the $2 \times 2$ rectangle can be cut into two $1 \times 2$ rectangles, and from these, the $1 \times 4$ rectangle can be formed.
In the fourth test case, the $3 \times 2$ rectangle can be cut into two $3 \times 1$ rectangles, and from these, the $1 \times 6$ rectangle can be formed.
In the fifth test case, the $2 \times 2$ rectangle can be cut into two $1 \times 2$ rectangles, and from these, the $1 \times 4$ rectangle can be formed.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted