Back
Close

Difference of Squares

Statement

 Goal

Given N, find a solution A, B to the equation: N^2 = A^2 - B^2

If multiple solutions are possible choose the one with smallest difference: d = A - B

It may also be helpful to consider the above difference when solving this clash...
Input
Integer N for the left side of the equation.
Output
Two space separated integers A and B for the right side of the equation.
Constraints
0 ≤ N ≤ 10000
0 ≤ BA
Example
Input
3
Output
5 4

Game modes
Fastest, Shortest

Test cases
Three Test
Input
3
Output
5 4

Five Validator
Input
5
Output
13 12

Four Test
Input
4
Output
5 3

Six Validator
Input
6
Output
10 8

Zero Test
Input
0
Output
0 0

Zero Validator
Input
0
Output
0 0

One Test
Input
1
Output
1 0

Two Validator
Input
2
Output
2 0

Test 15 Test
Input
15
Output
113 112

Validator 21 Validator
Input
21
Output
221 220

Test 28 Test
Input
28
Output
197 195

Validator 32 Validator
Input
32
Output
257 255

Test 9999 Test
Input
9999
Output
49990001 49990000

Validator 9997 Validator
Input
9997
Output
49970005 49970004

Test 10000 Test
Input
10000
Output
25000001 24999999

Validator 9998 Validator
Input
9998
Output
24990002 24990000

Solution language

Solution

Stub generator input