Description

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 calledPythagorean 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
3
output
4 5
input
6
output
8 10
input
1
output
-1
input
17
output
144 145
input
67
output
2244 2245

正解:数学(数论)
解题报告:
  n<=2显然无解。
  若n为奇数,则另两个为(a*a-1)/2和(a*a+1)/2;
  若n为偶数,则另两个为(a/2)*(a/2)-1和(a/2)*(a/2)+1
 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n;
LL a,b; inline int getint(){
int w=,q=;char c=getchar();
while(c!='-' && (c<'' || c>'')) c=getchar();
if(c=='-') q=-,c=getchar();
while(c>='' && c<='') w=w*+c-'',c=getchar();
return w*q;
} int main()
{
n=getint();
if(n<=) printf("-1");
else if(n&) {
a=n*n-; a/=; b=a+;
printf("%I64d %I64d",a,b);
}
else {
n/=;
a=n*n-; b=n*n+;
printf("%I64d %I64d",a,b);
}
return ;
}

codeforces707C:Pythagorean Triples的更多相关文章

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

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

  2. Pythagorean Triples

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

  3. Pythagorean Triples 707C

    Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theor ...

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

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

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

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

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

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

  7. codeforces-707 C. Pythagorean Triples

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

  8. CodeForces 707C Pythagorean Triples (数论)

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

  9. 【数学】Codeforces 707C Pythagorean Triples

    题目链接: http://codeforces.com/problemset/problem/707/C 题目大意: 给你一个数,构造其余两个勾股数.任意一组答案即可,没法构造输出-1. 答案long ...

随机推荐

  1. 【BZOJ1925】[Sdoi2010]地精部落 组合数+DP

    [BZOJ1925][Sdoi2010]地精部落 Description 传说很久以前,大地上居住着一种神秘的生物:地精. 地精喜欢住在连绵不绝的山脉中.具体地说,一座长度为 N 的山脉 H可分 为从 ...

  2. node.js 关于跨域和传递给前台参数

    /*为app添加中间件处理跨域请求*/ app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin& ...

  3. JQUERY几个操作action,随意记录

    .click:鼠标单击 .mouseenter 鼠标滑动

  4. Maven国内高速镜像

    大家都知道国外Maven中央仓库下载jar 没谁了速度, 给大家分享个国内666的Maven镜像 阿里云Maven镜像  希望能帮到大家: 配置下setting.xml即可: <mirrors& ...

  5. 【转】jstack简单使用

    转载记录下, 转载自https://www.cnblogs.com/chenpi/p/5377445.html 当我们运行java程序时,发现程序不动,但又不知道是哪里出问题时,可以使用JDK自带的j ...

  6. JavaWeb 过滤器应用之页面静态化

    页面静态化是把servlet请求的资源所做输出保存到html中, 然后重定向到 html 页面, 二次访问时,这个html已经存在,那么直接重定向,不用再去访问servlet! // StaticFi ...

  7. badboy脚本参数化和检查点

    一.badboy脚本参数化 文本参数化 方式一:直接在Variablesl ist添加参数化变量和值,然后在Script里面找到对应需要参数化的内容-属性,进行替换,参数化名需要用${XX}引用: 方 ...

  8. Nuxt使用element-ui

    废话不多说,在Nuxt中引入Nuxt其实很简单,分下面几步 一.安装element-ui依赖 打开nuxt项目以后,在Terminal中通过 npm i element-ui -S 即可安装eleme ...

  9. 免费 SSL 安全证书

    为了保证网上传输信息的安全而在自己的 Linode VPS 上部署 SSL 加密服务.商业 CA 较贵,所以使用了自己签发的 CA.网友神爱的留言提到了 StartSSL 的免费 CA,稍做了一些调查 ...

  10. 008-ThreadLocal

    一.基本用法 ThreadLocal是一个容器,用于存放线程的局部变量.如果ThreadLocalVariable(线程局部变量)更加好理解. 在Jdk 1.2 java.lang.ThreadLoc ...