Submit | All submissions | Best solutions | Back to list |
APM - Abul and Prime Numbers |
Mr. Abul is a big fan of prime numbers. As a fan of prime numbers, he wants to know whether a prime number P can be expressed as difference of two squared numbers or not.
In other words you have to calculate two natural numbers X and Y where P = X^2 - Y^2
For example, prime number P = 5 can be expressed as 3^2 - 2^2 = 9 - 4 = 5, here X = 3 and Y = 2.
Input
Input starts with an integer T ≤ 100, denoting the number of test cases.
Each case contains an integer N (2 ≤ N ≤ 10^18) denoting a prime number.
Output
For each case of input, print X and Y separated by a space if it is possible to express as difference of two squared numbers. Otherwise, print -1.
Example
Input: 3 2 3 5 Output: -1 2 1 3 2
Added by: | Bappy |
Date: | 2019-10-07 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
2021-09-23 06:39:40 Waseem Ahmed
Simple math problem. Read the output description carefully. Got a WA because of that. |
|
2020-09-19 12:11:06
must do problem !! |
|
2020-06-22 15:13:57
must do problem !! |