ROOTCIPH - Decipher

Radar scanned the approaching enemy aircraft on the border. However due to some error part of the tranmitted data can't be deciphered. It was possible only to obtain the coefficients of the cubic polynomial, whose roots are the coordinates of the aircraft relative to the radar. Now you need to calculate the distance to the aircraft. Write the program to solve this task.

Input

The first line contains T (1 <= T <= 1000) - number tests. The next T lines contain three integers a, b and c - coefficients of the polynomial x3 + ax2 + bx + c, whose roots are the coordinates (the absolute value of the coordinates do not exceed 108).

Output

For each test print the square of the distance to the enemy aircraft.

Example

Input:
1
-6 11 -6

Output:
14

Added by:Spooky
Date:2010-03-09
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 SQLITE VB.NET
Resource:Advancement Spring 2010, http://sevolymp.uuuq.com/, author: Alexey Shchepin

hide comments
2021-11-12 23:30:31 vas14
You can use boost/multiprecision for a short and clean solution.
2020-04-20 17:52:44
C++ peeps, use scanf for input and cout for output; and if you have sync_with_stdio, comment it :)

Last edit: 2020-04-20 17:53:55
2019-08-20 13:29:51
2 -3 liner in python
2019-01-12 07:53:28
There are numbers in the input larger than the limit of a 64-bit signed integer. Scanf and cin react to overflowing input in different ways (look this up or experiment), which is why scanf solutions are succeeding and cin solutions are failing. I don't want to give too much away, but only the c coefficient overflows--this fact may help you create a 'workaround' once you figure out the solution (which isn't so easy IMO).

Last edit: 2019-01-12 08:32:55
2018-08-16 19:03:14
Dont use any cin cout instead use printf scanf dont know why it is happening.
2018-01-25 09:28:14
Why using cin gives WA but scanf gives AC?
2017-08-07 15:09:42
AC in one go :)
2017-06-22 08:18:21
To all the guys wondering why they are getting WAs with cin/cout, it's because coordinates can be as large as 100000000, and so the constant term in polynomial can be as large as 10**24 . use string for c and get AC :D
2017-06-08 13:47:38
using cin to take inputs of a,b,c gives WA, but using scanf for those values works!
2017-03-30 20:54:35
haha AC using scanf/printf WA in cin/cout
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.