Given three numbers A,B and C. Find roots of quadratic equation Ax^{2} + Bx + C = 0. (A not equal to  0)
 
Example 1:
Input: A = 2, B = 3, C = 2
Output: -2.366025, -0.633975
Explanation: Roots of the equation
2x^{2}+3x+2=0 are -2.366025 and -0.633975.
Example 2:
Input: A = 2, B = 3, C = 4
Output: -1
Explanation: Roots of 2x^{2} + 3x + 4 = 0
are not real.
 
Your Task:
You don't need to read or print anyhting. Your task is to complete the function FindRoots() which takes A, B and C as input parameters and returns a list of roots of the given equation in ascending order. If roots are not real numbers then return a list containing -1.
 
Expected Time Complexity: O(1)
Expected Space Complexity: O(1)
 
Constrains:
-100 <= A, B, C <= 100

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
	def FindRoots(self, A, B, C):
		# Code here

Solutions:
import math

class Solution:

	def FindRoots(self, A, B, C):
		d = B * B - 4 * A * C
		l = []
		if d > 0:
			r1 = -B + math.sqrt(d)
			r2 = -B - math.sqrt(d)
			r1 = r1 / (2 * A)
			r2 = r2 / (2 * A)
			l.append(r2)
			l.append(r1)
			l.sort()
			return l
		elif d == 0:
			r1 = -B / (2 * A)
			r2 = -B / (2 * A)
			l.append(r1)
			l.append(r2)
			return l
		else:
			l.append(-1)
			return l


class Solution:

	def FindRoots(self, A, B, C):
		ans = []
		D = B ** 2 - 4 * A * C
		if D >= 0:
			r1 = (-B + D ** 0.5) / (2 * A)
			r2 = (-B - D ** 0.5) / (2 * A)
			if r1 == int(r1):
				r1 = int(r1)
			if r2 == int(r2):
				r2 = int(r2)
			if (r1 == 0 or r2 == 0) and (r1 < 0 or r2 < 0):
				if max(r1, r2) == r1:
					r1 = -0.0
				else:
					r2 = -0.0
			ans.append(min(r1, r2))
			ans.append(max(r1, r2))
			return ans
		else:
			ans.append(-1)
			return ans


class Solution:

	def FindRoots(self, A, B, C):
		delta = B ** 2 - 4 * A * C
		if delta >= 0:
			return sorted([(-B - pow(delta, 0.5)) / (2 * A), (-B + pow(delta, 0.5)) / (2 * A)])
		else:
			return [-1]


import math

class Solution:

	def FindRoots(self, A, B, C):
		l = []
		d = B * B - 4 * A * C
		if d < 0:
			l.append(-1)
			return l
		x = math.sqrt(d)
		a = (-B - x) / (2 * A)
		b = (-B + x) / (2 * A)
		if a < b:
			l.append(a)
			l.append(b)
		else:
			l.append(b)
			l.append(a)
		return l


import math

class Solution:

	def FindRoots(self, A, B, C):
		if B * B - 4 * A * C < 0:
			return [-1]
		lst = [(-B - math.sqrt(B * B - 4 * A * C)) / (2 * A), (-B + math.sqrt(B * B - 4 * A * C)) / (2 * A)]
		lst.sort()
		return lst


class Solution:

	def FindRoots(self, A, B, C):
		import math
		d = B * B - 4 * A * C
		sq = math.sqrt(abs(d))
		s = []
		if d > 0:
			s1 = (-B + sq) / (2 * A)
			s2 = (-B - sq) / (2 * A)
			if s1 < s2:
				s.append(s1)
				s.append(s2)
			else:
				s.append(s2)
				s.append(s1)
		elif d == 0:
			s1 = s2 = -B / (2 * A)
			s.append(s1)
			s.append(s2)
		else:
			s1 = -1
			s.append(s1)
		return s
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		(A, B, C) = input().split()
		A = int(A)
		B = int(B)
		C = int(C)
		ob = Solution()
		ans = ob.FindRoots(A, B, C)
		if len(ans) == 1:
			print(int(ans[0]))
			continue
		for _ in ans:
			print('%.6f' % _, end=' ')
		print()


class Solution:

	def FindRoots(self, A, B, C):
		e = B * B - 4 * A * C
		if e < 0:
			return [-1]
		g = e ** 0.5
		f = 2 * A
		l = [(-B - g) / f, (-B + g) / f]
		l.sort()
		return l
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		(A, B, C) = input().split()
		A = int(A)
		B = int(B)
		C = int(C)
		ob = Solution()
		ans = ob.FindRoots(A, B, C)
		if len(ans) == 1:
			print(int(ans[0]))
			continue
		for _ in ans:
			print('%.6f' % _, end=' ')
		print()


import math

class Solution:

	def FindRoots(self, A, B, C):
		z = B * B - 4 * A * C
		if z <= -1:
			return [-1]
		k = math.sqrt(z)
		j = (-B - k) / (2 * A)
		h = (-B + k) / (2 * A)
		if j > h:
			return (h, j)
		else:
			return (j, h)
if __name__ == '__main__':
	T = int(input())
	for i in range(T):
		(A, B, C) = input().split()
		A = int(A)
		B = int(B)
		C = int(C)
		ob = Solution()
		ans = ob.FindRoots(A, B, C)
		if len(ans) == 1:
			print(int(ans[0]))
			continue
		for _ in ans:
			print('%.6f' % _, end=' ')
		print()


class Solution:

	def FindRoots(self, a, b, c):
		d = b ** 2 - 4 * a * c
		if d < 0:
			return (-1,)
		x1 = (-b + d ** 0.5) / (2 * a)
		x2 = (-b - d ** 0.5) / (2 * a)
		if x1 > x2:
			(x2, x1) = (x1, x2)
		return (x1, x2)


class Solution:

	def FindRoots(self, A, B, C):
		D = B ** 2 - 4 * A * C
		if D >= 0:
			r1 = (-B - D ** 0.5) / (2 * A)
			r2 = (-B + D ** 0.5) / (2 * A)
			if A > 0:
				R = [r1, r2]
			else:
				R = [r2, r1]
		else:
			R = [-1]
		return R


import math

class Solution:

	def FindRoots(self, a, b, c):
		delta = b * b - 4 * a * c
		sqrt_val = math.sqrt(abs(delta))
		if delta >= 0:
			return sorted([(-b - sqrt_val) / (2 * a), (-b + sqrt_val) / (2 * a)])
		else:
			return [-1]