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

网友投稿 759 2022-11-08

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

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

C. Pythagorean Triples

time limit per test

memory limit per test

input

output

Pythagorean triples.

(3, 4, 5), (5, 12, 13) and (6, 8, 10)

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

n (1 ≤ n ≤ 109) — the length of some side of a right triangle.

Output

m and k (1 ≤ m, k ≤ 1018), such that n, m and k

n, print  - 1

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.

题意:给你直角三角形的一边,让你求出其余的两边,要求是整数。

题解:数学构造题啊。直角三角形:k为奇:(2k+1,2k^2+2k,2k^2+2k+1)。 k为偶:(2k,k^2-1,k^2+1)

代码

#pragma comment(linker, "/STACK:102400000,102400000")//#include#include#include#include#include#include#include#include#include#include#include#include#include using namespace std;typedef long long ll;typedef unsigned long long ull;#define mst(a) memset(a, 0, sizeof(a))#define M_P(x,y) make_pair(x,y) #define rep(i,j,k) for (int i = j; i <= k; i++) #define per(i,j,k) for (int i = j; i >= k; i--) #define lson x << 1, l, mid #define rson x << 1 | 1, mid + 1, r const int lowbit(int x) { return x&-x; } const double eps = 1e-8; const int INF = 1e9+7; const ll inf =(1LL<<62) ;const int MOD = 1e9 + 7; const ll mod = (1LL<<32);const int N = 101010; const int M=100010; template inline void getmax(T1 &a, T2 b) {if (b>a)a = b;} template inline void getmin(T1 &a, T2 b) {if (b>n; if(n<=2) { puts("-1"); return 0; } if(n%2==1) { n>>=1; printf("%I64d %I64d\n",2*n*n+2*n,2*n*n+2*n+1); } else { n>>=1; printf("%I64d %I64d\n",n*n-1,n*n+1); } return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:docker: failed to register layer: devmapper: Unknown device
下一篇:Codeforces Round #368 (Div. 2) D. Persistent Bookcase (离线+dfs)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~