codeforces-707 C. Pythagorean Triples
1 second
256 megabytes
standard input
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?
The only line of the input contains single integer n (1 ≤ n ≤ 109) — the length of some side of a right triangle.
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.
3
4 5
6
8 10
1
-1
17
144 145
67
2244 2245
#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的更多相关文章
- codeforces 707C C. Pythagorean Triples(数学)
题目链接: C. Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【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.我们还可以发现, ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples 数学
C. Pythagorean Triples 题目连接: http://www.codeforces.com/contest/707/problem/C Description Katya studi ...
- Pythagorean Triples
Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Pythagorean Triples 707C
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theor ...
- Pythagorean Triples毕达哥斯拉三角(数学思维+构造)
Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...
- codeforces707C:Pythagorean Triples
Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pytha ...
随机推荐
- html提交表单到Servlet
源码地址 https://github.com/YouXianMing/Java-Web-Study/tree/master/Servlet-Form 演示效果(注意post与get提交方式浏览器地址 ...
- 简单了解weblogic配置文件
WebLogic的启动是通过启动文件来完成的 包括启动管理服务器(startWebLogic) 启动被管服务器(startManagedWebLogic) 设置域环境(setDomainEnv) 关闭 ...
- edis更新的正确方法
Redis更新的正确方法 https://www.cnblogs.com/westboy/p/8696607.html redis做缓存,怎么更新里面的数据 https://blog.csdn.net ...
- IIS 重写 HTTP 重定向到 HTTPS
1.购买SSL证书 2.IIS7 / IIS 7.5 下绑定 HTTPS 网站(购买Wildcard SSL泛域名证书可绑定多个子域名)参考上文 3.下载安装URL重写模块:Microsoft URL ...
- php : 文件及文件夹操作(创建、删除、移动、复制)
Talk is cheap, show you the code : <?php /** * 操纵文件类 * */ class FileUtil { /** * 建立文件夹 * * @param ...
- OpenLayers WorkShop 快速学习通道
学习地址:https://openlayers.org/workshop/en/ OpenLayers Workshop Introduction Basics Creating a map Zoom ...
- python 验证码识别示例(二) 复杂验证码识别
在这篇博文中手把手教你如何去分割验证,然后进行识别. 一:下载验证码 验证码分析,图片上有折线,验证码有数字,有英文字母大小写,分类的时候需要更多的样本,验证码的字母是彩色的,图片上有雪花等噪点,因 ...
- Android Studio添加原生库并自动构建
[时间:2017-09] [状态:Open] [关键词:Android,Android Studio,gradle,native,c,c++,cmake,原生开发,ndk-build] 0 引言 最近 ...
- Git入门到高级系列2-git高级操作
视频课程地址 腾讯课堂 git 清理 git clean命令用来从你的工作目录中删除所有没有tracked过的文件. 命令 说明 git clean -n 告诉你哪些文件会被删除. 记住他不会真正的删 ...
- Java多线程:volatile 关键字
一.内存模型的相关概念 大家都知道,计算机在执行程序时,每条指令都是在CPU中执行的,而执行指令过程中,势必涉及到数据的读取和写入.由于程序运行过程中的临时数据是存放在主存(物理内存)当中的,这时就存 ...
