探索flutter框架开发的app在移动应用市场的潜力与挑战
759
2022-11-08
Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学构造)
C. Pythagorean Triples
time limit per test
memory limit per test
input
output
Pythagorean triples.
(3, 4, 5), (5, 12, 13) and (6, 8, 10)
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
Input
n (1 ≤ n ≤ 109) — the length of some side of a right triangle.
Output
m and k (1 ≤ m, k ≤ 1018), such that n, m and k
n, print - 1
Examples
input
3
output
4 5
input
6
output
8 10
input
1
output
-1
input
17
output
144 145
input
67
output
2244 2245
Note
Illustration for the first sample.
题意:给你直角三角形的一边,让你求出其余的两边,要求是整数。
题解:数学构造题啊。直角三角形:k为奇:(2k+1,2k^2+2k,2k^2+2k+1)。 k为偶:(2k,k^2-1,k^2+1)
代码:
#pragma comment(linker, "/STACK:102400000,102400000")//#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~