C. Pythagorean Triples

链接:https://codeforces.com/problemset/problem/707/C

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 nm 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

Copy

3

output

Copy

4 5

input

Copy

6

output

Copy

8 10

input

Copy

1

output

Copy

-1

input

Copy

17

output

Copy

144 145

input

Copy

67

output

Copy

2244 2245

Note

Illustration for the first sample.

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,k,m;
int main()
{
	cin>>n;
	if(n==1||n==2)
	cout<<-1;
	else if(n%2==1)
	{
		m=(1+n*n)/2;
		k=m-1;
		if(m>n)
		cout<<k<<" "<<m;
	}
	else
	{
		m=(2+n*n/2)/2;
		k=m-2;
		if(m>n)
		cout<<k<<" "<<m;
	}
}

 

全部评论

相关推荐

昨天 20:52
武汉大学 Java
点赞 评论 收藏
分享
程序员花海:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
秋招吐槽大会
点赞 评论 收藏
分享
10-28 10:48
已编辑
门头沟学院 Java
孩子我想要offer:发笔试后还没笔试把我挂了,然后邮箱一直让我测评没测,后面不知道干嘛又给我捞起来下轮笔试,做完测评笔试又挂了😅
点赞 评论 收藏
分享
12-19 20:28
已编辑
门头沟学院 Java
美团履约 全栈工程师 (n+1)*15.5 其他
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务