思路:只需要百度一下勾股数...就有构造方法了...不多说
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
LL n;
scanf("%lld",&n);
if(n==1 || n==2)
{
puts("-1");
return 0;
}
if(n&1)
{
n -= 1;
n/=2;
printf("%lld %lld\n",2*n*n+2*n,2*n*n+2*n+1);
}
else
{
n/=2;
printf("%lld %lld\n",n*n-1,n*n+1);
}
}
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