您的位置:首页 > 编程语言 > Go语言

Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学构造)

2016-08-21 22:58 351 查看
C. Pythagorean Triples

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such
triples are called Pythagorean triples.

For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are
Pythagorean triples.

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

The only line of the input contains single integer n (1 ≤ n ≤ 109) —
the length of some side of a right triangle.

Output

Print two integers m and k (1 ≤ m, k ≤ 1018),
such that n, m and k form
a Pythagorean triple, in the only line.

In case if there is no any Pythagorean triple containing integer n, print  - 1 in
the only line. If there are many answers, print any of them.

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<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<set>
#include<stack>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define mst(a) memset(a, 0, sizeof(a))
#define M_P(x,y) make_pair(x,y)
#define rep(i,j,k) for (int i = j; i <= k; i++)
#define per(i,j,k) for (int i = j; i >= k; i--)
#define lson x << 1, l, mid
#define rson x << 1 | 1, mid + 1, r
const int lowbit(int x) { return x&-x; }
const double eps = 1e-8;
const int INF = 1e9+7;
const ll inf =(1LL<<62) ;
const int MOD = 1e9 + 7;
const ll mod = (1LL<<32);
const int N = 101010;
const int M=100010;
template <class T1, class T2>inline void getmax(T1 &a, T2 b) {if (b>a)a = b;}
template <class T1, class T2>inline void getmin(T1 &a, T2 b) {if (b<a)a = b;}
int read()
{
int v = 0, f = 1;
char c =getchar();
while( c < 48 || 57 < c ){
if(c=='-') f = -1;
c = getchar();
}
while(48 <= c && c <= 57)
v = v*10+c-48, c = getchar();
return v*f;
}

int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
ll n;
cin>>n;
if(n<=2)
{
puts("-1");
return 0;
}

if(n%2==1)
{
n>>=1;
printf("%I64d %I64d\n",2*n*n+2*n,2*n*n+2*n+1);

}
else
{
n>>=1;
printf("%I64d %I64d\n",n*n-1,n*n+1);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: