链接: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;}
}

C. Pythagorean Triples相关推荐

  1. D. Pythagorean Triples(1487D)(打表找规律 + 二分)

    D. Pythagorean Triples(1487D)(打表找规律 + 二分) 题目来源:D. Pythagorean Triples 题意: 给定一个 n,求满足以下条件的数对 (a, b, c ...

  2. hdu2017青岛网络赛Pythagoras(Tree of primitive Pythagorean triples)

    题面: Given a list of integers a0,a1,a2,⋯,a2k−1. Pythagoras triples over 109 are all solutions of x2+y ...

  3. python:实现Pythagorean triples毕氏三元数(附完整源码)

    python:实现Pythagorean triples毕氏三元数 limit = int(input("Enter upper limit:")) c = 0 m = 2 whi ...

  4. CF707C Pythagorean Triples 题解

    CF707C Pythagorean Triples 题解 题目 链接 字面描述 题面翻译 题目描述 输入格式 输出格式 样例 #1 样例输入 #1 样例输出 #1 样例 #2 样例输入 #2 样例输 ...

  5. JAVA:实现是否为Pythagorean Triples毕达哥斯拉三角数算法(附完整源码)

    JAVA:实现是否为Pythagorean Triples毕达哥斯拉三角数算法 package com.thealgorithms.maths;public class PythagoreanTrip ...

  6. D. Pythagorean Triples

    题目来源 一.题目 A Pythagorean triple is a triple of integer numbers (a,b,c) such that it is possible to fo ...

  7. Codeforces Round #368 (Div. 2) problem: (C) Pythagorean Triples

    本题就一个公式 n^2+((n^2-1)/2)^2=((n^2+1)/2)^2 0.当n==1或n==2时,不存在结果. 1.当n为奇数时此公式求得的数还是整数,成立 2.当n为偶数时分两种情况: ( ...

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

    题目链接:http://codeforces.com/contest/707/problem/C 题意: 直角三角形的三边都为整数,给出其中一边n,求另外两边m.k. (1 ≤ n ≤ 109)  ( ...

  9. Codeforces-1487 D. Pythagorean Triples(数学)

    思路: 数学题,打表可以找出规律,不过我们也可以推一下. c2=a2+b2c^2 = a^2 + b^2c2=a2+b2 c=a2−bc = a^2 - bc=a2−b ⇒\Rightarrow⇒c2 ...

最新文章

  1. Highlight – 代码高亮html输出软件
  2. 虚拟机在Hyper-V和Citrix Xenserver上的区别
  3. GP学习(二)—Executing tools and Accesubg licensing0
  4. android源码出现的@字符代表什么意思
  5. C++安全方向(三)3.3 openssl的MD5接口调用演示
  6. Maven学习总结(18)——深入理解Maven仓库
  7. 程序员的内功修炼——值得看的9本书
  8. bootstrap table 服务器端分页--ashx+ajax
  9. MongoDB 固定集合详解
  10. 将CString转换成string ...
  11. android正确释放webview,解决Android WebView内存释放
  12. Macbook M1 安装node(亲测)
  13. python处理字符串(SQL语句批量新增)
  14. webApp——媒体查询
  15. 运动员和教练案例分析
  16. 搜索引擎优化技巧解读
  17. 新手小白都看得懂得光通信知识
  18. ic集成电路专业通信计算机咋选,2021年美国留学研究生EE专业详解,选校选专业必备!...
  19. 前端(js/css/html)那些小的知识点,持续更新......
  20. DIY大神分享:i7 10700k和r53600哪个好-对比性能有什么区别

热门文章

  1. 微信公众号音乐html,如何在微信公众号文章内插入音频及样式?
  2. 哪位大神能帮我解读下这段代码什么意思吗???万分感谢
  3. Mac 活动监视器 闪退 打不开
  4. 史上最全数据库笔记(上)
  5. 招银网络 Java后端面经
  6. Java二维码编码识别
  7. FPGA图像处理 浅浅浅浅浅记
  8. 钉钉群机器人关键词自动回复_wetool自动接受新好友wetool pc版-客服
  9. 科技圈的“三座大山”正在崩塌中。。。
  10. hdu 校赛 油菜花王国