<Sicily>Pythagorean Proposition

这篇博客介绍了如何帮助WXYZ将木棍分割成三段,形成不同的直角三角形。题目要求输入木棍的长度,然后找出所有可能的直角三角形组合。解题思路是从1开始遍历,检查两条直角边的平方和是否等于第三边的平方,以确定毕达哥拉斯三角形。代码实现中包含了详细的测试用例和输出格式说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、题目描述

One day, WXYZ got a wooden stick, he wanted to split it into three sticks and make a right-angled triangle. You will be given the length of the stick, and your task is to help WXYZ to find all different right triangles that can be made.

二、输入

The first line of the input is a positive integer T. T is the number of test cases followed. Each test case contains a integer L (1<=L<=1000), representing the length of the stick.

三、输出

For each test case, output all different right-angled triangles. For each triangle, output one line containing three integers X Y Z, (1<=X<=Y<=Z, X*X+Y*Y=Z*Z). All triangles are sorted in lexicographical order.

Output a blank line after each test case.
例如:
输入:
3
40
50
60
输出:
8 15 17

10 24 26

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值