Submit | All submissions | Best solutions | Back to list |
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
|
||||||
2010-04-15 10:19:03 Spooky
I can only say that this problem can be solved only using 64-bit signed integers... neither doubles nor long arithmetics are necessary for it... |