largest-volume-84
Source: hackerearth
Difficulty: MEDIUM

Now our heroes - Maga and Alex are working for Oil Company as developers. Recently they have faced a great problem. 

They couldn’t find the correct solution. Could you help them?

We are given r – radius of lower base and s – slant height. The figure can be cylinder or truncated cone. You have to find as largest volume as possible to carry oil respect to given information. The slant height is the shortest possible distance between the edges of two bases through surface of cone.

  

Input :

You are given 2 numbers. r– radius of lower base and s – slant height.

Output:

Largest Volume. Print 2 digits after floating point.

Constraints:

1 ≤ r, s ≤ 100

SAMPLE INPUT
1 1

SAMPLE OUTPUT
4.33

Explanation

In the sample test case, the answer is that it is truncated cone which the area of upper base is larger than the area of lower base. And then answer is simple 4.33.


import math

r, s = list(map(float, input().split()))

max_vol = 0.00

R = r
while R < s+r:
	h = math.sqrt(s**2-(R-r)**2)
	
	v = (1/3.0)*math.pi*h*(R**2+r**2+R*r)
	
	if v > max_vol:
		max_vol = v
	
	R += 0.0001

b = str(max_vol).split('.')
if len(b[1]) < 2:
	while len(b[1]) < 2:
		b[1] += '0'

print("%.2f" % max_vol)


import math

r, s = list(map(float, input().split()))

max_vol = 0.00

R = r
while R < s+r:
	h = math.sqrt(s**2-(R-r)**2)
	
	v = (1/3.0)*math.pi*h*(R**2+r**2+R*r)
	
	if v > max_vol:
		max_vol = v
	
	R += 0.0001

b = str(max_vol).split('.')
if len(b[1]) < 2:
	while len(b[1]) < 2:
		b[1] += '0'
		
#print "%s.%s" % (b[0], b[1][:2])

print("%.2f" % max_vol)
#ans = str("%.12f" % max_vol)
#print ans[:-10]


import numpy as np
r1,s = input().split()
r1 = int(r1)
s = int(s)
maximum = 0
maxtheta = 0
for theta in range(0,90):
	r2 = r1+s*np.sin(np.deg2rad(theta))
	r = (r1**2+r1*r2+r2**2)
	h = s*np.cos(np.deg2rad(theta))
	vol = (np.pi/3)*r*h
	#print theta,vol
	if(vol>maximum):
		maximum = vol
		maxtheta = theta
theta=maxtheta-1
for i in range(2000):
	r2 = r1+s*np.sin(np.deg2rad(theta+i/1000.0))
	r = (r1**2+r1*r2+r2**2)
	h = s*np.cos(np.deg2rad(theta+i/1000.0))
	vol = (np.pi/3)*r*h
	#print theta+i/1000.0,vol
	if(vol>maximum):
		maximum = vol
		maxtheta = theta+i/1000.0
print("{0:.2f}".format(maximum))


import numpy as np
r1,s = input().split()
r1 = int(r1)
s = int(s)
maximum = 0
maxtheta = 0
for theta in range(0,90):
	r2 = r1+s*np.sin(np.deg2rad(theta))
	r = (r1**2+r1*r2+r2**2)
	h = s*np.cos(np.deg2rad(theta))
	vol = (np.pi/3)*r*h
	#print theta,vol
	if(vol>maximum):
		maximum = vol
		maxtheta = theta
theta=maxtheta-1
for i in range(2000):
	r2 = r1+s*np.sin(np.deg2rad(theta+i/1000.0))
	r = (r1**2+r1*r2+r2**2)
	h = s*np.cos(np.deg2rad(theta+i/1000.0))
	vol = (np.pi/3)*r*h
	#print theta+i/1000.0,vol
	if(vol>maximum):
		maximum = vol
		maxtheta = theta+i/1000.0
s = "{0:.2f}".format(maximum)
print(s[:len(s)])


import numpy as np
r1,s = input().split()
r1 = int(r1)
s = int(s)
maximum = 0
maxtheta = 0
for theta in range(0,90):
	r2 = r1+s*np.sin(np.deg2rad(theta))
	r = (r1**2+r1*r2+r2**2)
	h = s*np.cos(np.deg2rad(theta))
	vol = (np.pi/3)*r*h
	#print theta,vol
	if(vol>maximum):
		maximum = vol
		maxtheta = theta
theta=maxtheta-1
for i in range(2000):
	r2 = r1+s*np.sin(np.deg2rad(theta+i/1000.0))
	r = (r1**2+r1*r2+r2**2)
	h = s*np.cos(np.deg2rad(theta+i/1000.0))
	vol = (np.pi/3)*r*h
	#print theta+i/1000.0,vol
	if(vol>maximum):
		maximum = vol
		maxtheta = theta+i/1000.0
print("{0:.2f}".format(maximum))


import math
r,s=list(map(int,input().split()))
max_V=0
R=r
h=s
while h>=0:
	t=s**2-(R-r)**2
	if t<0:
		break
	h=t**.5
	V=(math.pi*h)*(r**2+R**2+R*r)/3.0
	if V>=max_V:
		max_V=V
	R=R+0.001
	
print("%0.2f" % max_V)	


import math
r,s=list(map(int,input().split()))
max_V=0
R=r
h=s
while h>=0:
	t=s**2-(R-r)**2
	if t<0:
		break
	h=t**.5
	V=(math.pi*h)*(r**2+R**2+R*r)/3.0
	if V>=max_V:
		max_V=V
	R=R+0.001
	
print("%0.2f" % max_V)	


import math
r,s=list(map(int,input().split()))
max_V=0
R=r
h=s
while h>=0:
	t=s**2-(R-r)**2
	if t<0:
		break
	h=t**.5
	V=(math.pi*h)*(r**2+R**2+R*r)/3.0
	if V>=max_V:
		max_V=V
	R=R+0.001
	
print("%0.2f" % max_V)