QOJ.ac

QOJ

時間限制: 3 s 記憶體限制: 2048 MB 總分: 100 难度: [顯示] 可 Hack ✓

#8779. 三角形的平方

统计

给定四个三角形各边长度的平方,判断是否可以将它们(通过平移、旋转和翻转)拼成一个正方形。三角形之间不得重叠,且拼成的正方形内不得有空隙或孔洞。

图 1:样例输入中第三组测试数据的解法。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 20$),表示测试用例的数量。 接下来的 $4 \cdot t$ 行描述了 $t$ 组测试用例,每组包含四个三角形,每行一个三角形。每个三角形由三个整数 $a, b, c$ ($1 \le a, b, c \le 10^7$) 组成。每个整数等于三角形某条边长度的平方。例如,如果三角形的三条边长分别为 3、4 和 5,则输入为 9 16 25。这些整数不一定是完全平方数。保证给定的三元组均能构成面积为正的三角形。

输出格式

输出 $t$ 行。对于每组测试用例,按顺序输出一行一个整数,如果这四个三角形可以拼成一个正方形,则输出 1,否则输出 0。

样例

输入 1

3
1 1 2
2 1 1
2 1 1
1 2 1
1 1 1
1 1 1
1 1 1
1 1 1
5 125 130
125 20 145
45 130 145
145 145 80

输出 1

1
0
1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.