A13545 | Minimal Square
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Find the minimum area of a square land on which you can place two identical rectangular $a \times b$ houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
- You are given two identical rectangles with side lengths $a$ and $b$ ( $1 \le a, b \le 100$ ) — positive integers (you are given just the sizes, but not their positions).
- Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
The picture shows a square that contains red and green rectangles.
Formally,
- You are given two identical rectangles with side lengths $a$ and $b$ ( $1 \le a, b \le 100$ ) — positive integers (you are given just the sizes, but not their positions).
- Find the square of the minimum area that contains both given rectangles. Rectangles can be rotated (both or just one), moved, but the sides of the rectangles should be parallel to the sides of the desired square.
Two rectangles can touch each other (side or corner), but cannot intersect. Rectangles can also touch the sides of the square but must be completely inside it. You can rotate the rectangles. Take a look at the examples for a better understanding.
The picture shows a square that contains red and green rectangles.
输入格式
The first line contains an integer $t$ ( $1 \le t \le 10\,000$ ) —the number of test cases in the input. Then $t$ test cases follow.
Each test case is a line containing two integers $a$ , $b$ ( $1 \le a, b \le 100$ ) — side lengths of the rectangles.
Each test case is a line containing two integers $a$ , $b$ ( $1 \le a, b \le 100$ ) — side lengths of the rectangles.
输出格式
Print $t$ answers to the test cases. Each answer must be a single integer — minimal area of square land, that contains two rectangles with dimensions $a \times b$ .
输入输出样例
输入 #1
8 3 2 4 2 1 1 3 1 4 7 1 3 7 4 100 100
输出 #1
16 16 4 9 64 9 64 40000
Below are the answers for the first two test cases:
 
 
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted