John was given a task to make a rectangular box during his innovation competition. He was given with
the A cm of wire and B cm^{2} of special paper. He had to use all the wire (for the 12 edges) and paper (for the 6 sides) to make the box. So what will be the maximum volume of that box?
 
Example 1:
Input:
A = 20, B = 14
Output:
3
Explanation:
The maximum volumed Rectangular
Box we can get is 3cm^{3}.
Example 2:
Input:
A = 20, B = 16
Output:
4
Explanation:
The maximum volumed Rectangular
Box we can get is 4cm^{3}.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function getVol() which takes 2 Integers A, and B as input and returns the answer.
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= A,B <= 10^{6}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def getVol(self, A, B):

        # code here

Solutions:
from math import *

class Solution:

	def getVol(self, A, B):
		l = (A - math.sqrt(A * A - 24 * B)) / 12
		V = l * (B / 2.0 - l * (A / 4.0 - l))
		return int(V)


import math

class Solution:

	def getVol(self, A, B):
		a = 36 * A * B - A ** 3
		b = A * A - 24 * B
		c = math.sqrt(b ** 3)
		d = a + c
		e = 12 * 72
		v = d / e
		return int(v)


class Solution:

	def getVol(self, P, A):
		l = (P - (P * P - 24 * A) ** 0.5) / 12
		V = l * (A / 2.0 - l * (P / 4.0 - l))
		return int(V)


class Solution:

	def getVol(self, A, B):
		ans = (36 * A * B - math.pow(A, 3) + math.sqrt(math.pow(A * A - 24 * B, 3))) / (12 * 72)
		if ans < 0:
			ans = 0
		return int(ans)


import math

class Solution:

	def getVol(self, A, B):
		l = (A - math.sqrt(A * A - 24 * B)) / 12
		v = l * B / 2 - l * l * (A / 4 - l)
		return int(v)


class Solution:

	def getVol(self, A, B):
		x = math.sqrt(A * A - 24 * B)
		L = (A - x) / 12
		w = L * B / 2
		y = A * L * L / 4
		z = L * L * L
		vol = int(w - y + z)
		return vol


class Solution:

	def getVol(self, P, A):
		l = (P - math.sqrt(P * P - 24 * A)) / 12
		V = l * (A / 2.0 - l * (P / 4.0 - l))
		return int(V)


class Solution:

	def getVol(self, A, B):
		h = (A - math.sqrt(A * A - 24 * B)) / 12
		volume = B * h / 2 - h * h * A / 4 + h * h * h
		return int(volume)


class Solution:

	def getVol(self, A, B):
		ans = (36 * A * B - math.pow(A, 3) + math.sqrt(math.pow(A * A - 24 * B, 3))) / (12 * 72)
		if ans < 0:
			ans = 0
		return int(ans)
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(A, B) = map(int, input().split())
		ob = Solution()
		print(ob.getVol(A, B))


from math import sqrt

class Solution:

	def getVol(self, A, B):
		l = (A - math.sqrt(A ** 2 - 24 * B)) / 12
		V = l * (B / 2.0 - l * (A / 4.0 - l))
		return int(V)
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(A, B) = map(int, input().split())
		ob = Solution()
		print(ob.getVol(A, B))


class Solution:

	def getVol(self, A, B):
		l = (A - (A ** 2 - 24 * B) ** (1 / 2)) / 12
		v = l * (B / 2 - l * (A / 4 - l))
		return int(v)
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(A, B) = map(int, input().split())
		ob = Solution()
		print(ob.getVol(A, B))


import math

class Solution:

	def getVol(self, A, B):
		h = (A - math.sqrt(A * A - 24 * B)) / 12
		volume = B * h / 2 - h * h * A / 4 + h * h * h
		return int(volume)
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(A, B) = map(int, input().split())
		ob = Solution()
		print(ob.getVol(A, B))


class Solution:

	def getVol(self, A, B):
		h = (A / 2 - math.sqrt(A * A / 4 - 6 * B)) / 6
		v = B * h / 2 - h * h * A / 4 + h * h * h
		return int(v)
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(A, B) = map(int, input().split())
		ob = Solution()
		print(ob.getVol(A, B))


class Solution:

	def getVol(self, p, a):
		l = (p - (p * p - 24 * a) ** 0.5) / 12
		v = l * (a / 2) - l ** 2 * (p / 4) + l ** 3
		return int(v)
import math
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(A, B) = map(int, input().split())
		ob = Solution()
		print(ob.getVol(A, B))


from math import sqrt

class Solution:

	def getVol(self, P, A):
		l = (P - sqrt(P * P - 24 * A)) / 12
		v = l * (A / 2.0 - l * (P / 4.0 - l))
		return int(v)


import math

class Solution:

	def getVol(self, a, b):
		l = (a - math.sqrt(a * a - 24 * b)) / 12
		V = l * (b / 2.0 - l * (a / 4.0 - l))
		return int(V)


class Solution:

	def getVol(self, A, B):
		length1 = (A / 2 + math.sqrt(A * A / 4 - 4 * 3 * (B / 2))) / 6
		length2 = (A / 2 - math.sqrt(A * A / 4 - 4 * 3 * (B / 2))) / 6
		volume1 = length1 * length1 * length1 - A / 4 * (length1 * length1) + B / 2 * length1
		volume2 = length2 * length2 * length2 - A / 4 * (length2 * length2) + B / 2 * length2
		if volume1 > volume2:
			return int(volume1)
		else:
			return int(volume2)


class Solution:

	def getVol(self, A, B):
		v = (36 * A * B - math.pow(A, 3) + math.sqrt(math.pow(A * A - 24 * B, 3))) / (12 * 72)
		return int(v)


class Solution:

	def getVol(self, A, B):
		length = (A - math.sqrt(A * A - 24 * B)) / 12
		volume = length * (B / 2.0 - length * (A / 4.0 - length))
		return int(volume)


class Solution:

	def getVol(self, A, B):
		length = (A - (A * A - 24 * B) ** (1 / 2)) / 12
		volume = length * (B / 2.0 - length * (A / 4.0 - length))
		return int(volume)


class Solution:

	def getVol(self, A, B):
		a = 3
		b = -A / 2
		c = B / 2
		s = b * b - 4 * a * c
		d = math.sqrt(abs(s))
		x1 = (-b + d) / (2 * a)
		x2 = (-b - d) / (2 * a)
		ans1 = -(x1 * x1 * A / 4) + B * x1 / 2 + x1 * x1 * x1
		ans2 = -(x2 * x2 * A / 4) + B * x2 / 2 + x2 * x2 * x2
		if ans1 > ans2:
			return int(ans1)
		else:
			return int(ans2)


class Solution:

	def getVol(self, A, B):
		import math
		h0 = 1 / 6 * (A / 2 + math.sqrt(A * A / 4 - 6 * B))
		h1 = 1 / 6 * (A / 2 - math.sqrt(A * A / 4 - 6 * B))
		vh0 = h0 ** 3 - h0 * h0 * A / 4 + B * h0 / 2
		vh1 = h1 ** 3 - h1 * h1 * A / 4 + B * h1 / 2
		l = [vh0, vh1]
		l.sort()
		return int(l[1])