Roots of Quadratic Equation
Submissions: 3835   Accuracy:

18.07%

  Difficulty: Basic   Marks: 1

Given a quadratic equation in the form ax2 + bx + c. The task is to find the floor of roots of it.  For example, floor of 5.6 is 5.

Input: 
First line of input contains an integer, the number of test cases T. Each test case should contain three positive numbers a, b and c in the same line seperated by space.

Output: 
If roots of equations exists, then print the two roots separated by space (Higher valued root should be printed before lower valued). Else if a = 0, then print "Invalid" as equation is not quadratic.  If roots are imaginary, then print "Imaginary"

Constraints:
1 <= T <= 50
-103 <= a <= 103
-103 <= b <= 103
-103 <= c <= 103

Example:
Input:
3
1 -2 1
1 -7 12
1 4 8

Output:
1 1
4 3
Imaginary

Explanation:
Testcase 1:
Roots of equation x2 - 7x + 12 are 4 and 3.
Testcase 3: Roots of equation x2 + 4x + 8 are imaginary since it's discriminant is less than 0.

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: kartik


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.