#P9783. Difference of Squares

    ID: 22929 Type: Default 1000ms 256MiB

Difference of Squares

Difference of Squares

This problem is adapted from ROIR 2020 Day1 T1 (Разность квадратов) translated by ShineEternal.

You are working on a module for a character calculation system where you need to solve a special Diophantine equation. Given a non-negative integer \(n\), your task is to find two positive integers \(x\) and \(y\) (with \(x, y \le 2^{62}-1\)) such that:

[ x^2 - y^2 = n ]

If \(n = 0\), you may output \(x = y\) (for example, 1 1). If no valid pair exists, output -1.

inputFormat

The input consists of a single non-negative integer \(n\) (\(0 \le n\)).

outputFormat

If there exists a valid pair \((x, y)\) (with \(x,y \le 2^{62}-1\)) such that \(x^2 - y^2 = n\), output the two numbers separated by a space. Otherwise, output -1.

sample

0
1 1