D |
Sum of Four Squares |
You will be given an integer n, and you will have to express as summation of four square-numbers.
For example 30 can be written as summation of four squares in the following way:
30 = 4*4 +3*3 +2*2 + 1*1
If a number can be expressed as summation of four squares in more than one ways, any one of them will do. A square is a number whose square root is also an integer.
Input starts with an integer T (≤ 120000), denoting the number of test cases.
Each case contains an integer n (0 ≤ n < 1017) in a line.
For each case, print a line containing four integer numbers a, b, c, d such that
n = a2 + b2 + c2 + d2
If the number cannot be expressed as summation of four squares then you should print "Impossible." instead.
Sample Input |
Output for Sample Input |
3 30 2 0 |
5 2 0 1 1 0 0 1 0 0 0 0 |
As the size of the input file is large, so use faster I/O functions like scanf(), printf().
Problem Setter: Shahriar Manzoor, Special Thanks: Jane Alam Jan