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.

题意:给你一条直角边,让你求出另一条直角边与斜边,如果没有,则输出-1

分析:a²+b²=c²,a²=(c-b)(c+b),如果a是奇数,c-b=1,c+b=a*a,c=a*a+1/2, b=c-1.如果a是偶数,先判断,1:如果不断的除2,是否是奇数,是奇数就执行c=a*a+1/2, b=c-1;2:当其不断除2等于4时,执行c=5,b=3;

 #include<cstdio>
int main()
{
long long n;
while(~scanf("%lld",&n))
{
long long b,c;
if(n%!=)//当直角边时奇数的时候直接执行
{
b=(n*n-)/;
c=b+;
if(b==)
printf("-1\n");
else
printf("%lld %lld\n",b,c);
}
else//当直角边是偶数的时候
{
long long t=;
while()
{
if(n==)
break;
if(n%!=)
break;
n/=;
t*=; }//不断除2,看其是否为奇数,或者不断除2等于4
if(n==)
{
b=;
c=;
b*=t;
c*=t;
}//如果等于4就满足,a=,b=,a=5的情况
else
{
b=(n*n-)/;
c=b+;
b*=t;
c*=t;
}//否则就满足a是奇数的情况
if(b==)
printf("-1\n");
else
printf("%lld %lld\n",b,c);
}
}
return ;
}

Pythagorean Triples 707C的更多相关文章

  1. codeforces 707C C. Pythagorean Triples(数学)

    题目链接: C. Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input ...

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

    Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...

  3. Pythagorean Triples

    Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. codeforces-707 C. Pythagorean Triples

    C. Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input standa ...

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

    C. Pythagorean Triples 题目连接: http://www.codeforces.com/contest/707/problem/C Description Katya studi ...

  6. Pythagorean Triples毕达哥斯拉三角(数学思维+构造)

    Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...

  7. codeforces707C:Pythagorean Triples

    Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...

  8. 【Codeforces 707C】Pythagorean Triples(找规律)

    一边长为a的直角三角形,a^2=c^2-b^2.可以发现1.4.9.16.25依次差3.5.7.9...,所以任何一条长度为奇数的边a,a^2还是奇数,那么c=a^2/2,b=c+1.我们还可以发现, ...

  9. CodeForces 707C Pythagorean Triples (数论)

    题意:给定一个数n,问你其他两边,能够组成直角三角形. 析:这是一个数论题. 如果 n 是奇数,那么那两边就是 (n*n-1)/2 和 (n*n+1)/2. 如果 n 是偶数,那么那两边就是 (n/2 ...

随机推荐

  1. windows10如何查看wifi密码

    1.首先,在你的电脑的右下角的WiFi的图标,右击它,选择"网络和internet设置"或者选择打开设置 :如下图 点击"更改适配器选项" 选择 WLAN选项, ...

  2. CLion使用OpenCV(Ubuntu 18.04)

    项目结构: 设置CMainLists.txt文件中的内容: cmake_minimum_required(VERSION 3.13) project(cv_test) ) find_package(O ...

  3. 第41课 kmp子串查找算法

    1. 朴素算法的改进 (1)朴素算法的优化线索 ①因为 Pa != Pb 且Pb==Sb:所以Pa != Sb:因此在Sd处失配时,子串P右移1位比较没有意义,因为前面的比较己经知道了Pa != Sb ...

  4. AWS之SSH登录:使用 PuTTY 从 Windows 连接到 Linux 实例

    使用 PuTTY 从 Windows 连接到 Linux 实例 启动您的实例之后,您可以连接到该实例,然后像使用您面前的计算机一样来使用它. 注意 启动实例后,需要几分钟准备好实例,以便您能连接到实例 ...

  5. Unity读取Android SDcard文件

    一.添加权限 权限添加 :Player settings -- Other settings -- write permission的设置 Sdcard.这个是在Unity编辑器里打包的情况. 如果导 ...

  6. c# 未能加载文件或程序集

    最近做项目时碰到这个问题了,goole.百度了半天,整理了以下几种可能: DLL文件名与加载时的DLL文件名不一致, DLL文件根本不存在,即出现丢失情况, 加载DLL路径错误,即DLL文件存在,但加 ...

  7. Android仿淘宝头条滚动广告条

    之前我使用TextView+Handler+动画,实现了一个简单的仿淘宝广告条的滚动,https://download.csdn.net/download/qq_35605213/9660825: 无 ...

  8. 在django中使用django_debug_toolbar进行日志记录

    一.概述 django_debug_toolbar 是django的第三方工具包,给django扩展了调试功能. 包括查看执行的sql语句,db查询次数,request,headers,调试概览等.  ...

  9. bzoj2961 共点圆 (CDQ分治, 凸包)

    /* 可以发现可行的圆心相对于我们要查询的点是在一个半平面上, 然后我们要做的就是动态维护凸壳然后用这个半平面去切它 看看是否是在合法的那一面 然后cdq分治就可以了 代码基本是抄的, */ #inc ...

  10. angularjs的cache

    首先要引入angular-cookies.js插件 angular.module('app').service('cache', ['$cookies', function($cookies){ th ...