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.

看了好多个题解,感觉这个比较容易懂,这个题真的好锻炼思维。。。打死也想不到。。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; int main()
{
long long n;
while(~scanf("%lld",&n)){
if(n<=){
printf("-1\n");
}else{
if(n*n&){
printf("%lld %lld\n",(n*n-)/,(n*n+)/);
}else{
printf("%lld %lld\n",n*n/-,n*n/+);
}
}
} return ;
}

codeforces-707 C. Pythagorean Triples的更多相关文章

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

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

  2. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  3. 【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.我们还可以发现, ...

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

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

  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

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

  7. Pythagorean Triples 707C

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

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

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

  9. codeforces707C:Pythagorean Triples

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

随机推荐

  1. 使用docker搭建gitlab版本控制系统

    1. GitLab 简介 GitLab 是一款基于 git 的开源代码仓库系统   GitLab 与著名的 GitHub 最大的区别就是:  允许我们搭建自己的 git 代码私有仓库,非常方便   2 ...

  2. dotnet ef

    dotnet ef migrations add <Name-of-Migration> dotnet ef database update

  3. 阿里云物联网平台体验(树莓派+Nodejs篇)

    我们在<阿里云物联网平台体验(树莓派+python篇)>里,写了通过Python语言开发云到端的物联网程序,本篇文章将介绍通过nodejs来实现类似功能. 同样在阿里云官方文档里已经有了一 ...

  4. 关于4A(统一安全管理平台)系统的理解

    1. 4A系统的需求分析 近年来企业用户的业务系统发展十分迅速,内部的系统数和用户数不断增加,网络规模迅速扩大,在应用扩展的同时,各业务系统的安全管理工作相对滞后,无法满足企业发展的长期要求. 各系统 ...

  5. 单片机成长之路(51基础篇) - 013 MCS-51单片机控制详解–T2MOD

    T2CON:定时器控制寄存器 寄存器地址0C8H,位寻址0C8H-0CFH. 位地址 CF CE CD CC CB CA C9 C8 位符号 TF2 EXF2 RCLK TCLK EXEN2 TR2 ...

  6. myBase7 激活方法

    一.引言: 之前使用过一段时间的myBase,那时候发现还不太美观,所以弃用了一段时间,最近看到有myBase7出来,使用了一下感觉还可以,但是只能试用一个月,不过还好找到了破解的方法. 二.破解步骤 ...

  7. linux内核剖析(六)Linux系统调用详解(实现机制分析)

    本文介绍了系统调用的一些实现细节.首先分析了系统调用的意义,它们与库函数和应用程序接口(API)有怎样的关系.然后,我们考察了Linux内核如何实现系统调用,以及执行系统调用的连锁反应:陷入内核,传递 ...

  8. asp.net中WebResponse 跨域访问示例

    前两天,一个朋友让我帮他写这样一个程序:在asp.net里面访问asp的页面,把数据提交对方的数据库后,根据返回的值(返回值为:OK或ERROR),如果为OK再把填入本地数据库.当时,想当然,觉得很简 ...

  9. C# Cache缓存读取设置

    先创建一个CacheHelper.cs类,代码如下: using System; using System.Web; using System.Collections; using System.We ...

  10. ownCloud安卓android客户端版本2.9.3

    2018年11月26日 版本升级:ownCloud 2.9.3. 下载地址 2018年7月28日 版本升级:ownCloud 2.8.0,支持指纹.图案登录APP. 2018年2月6日 版本升级:ow ...