-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathEQBOX.py
More file actions
28 lines (23 loc) · 791 Bytes
/
EQBOX.py
File metadata and controls
28 lines (23 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Solution is based on the condition derived from the formula on the link: http://www.jstor.org/stable/2691523"""
from math import sqrt
t=input()
for i in range(t):
a,b,x,y=map(int,raw_input().split())
if (a>b): #make a smaller
temp=a
a=b
b=temp
if(x>y): #make x smaller
temp=x
x=y
y=temp
if(a>x and b>y):
print "Escape is possible."
continue
a,b,x,y= float(a),float(b),float(x),float(y)
val=abs(x**2 + y**2 - b**2) #To make sure val is not negetive otherwise sqrt will throw an error.
temp = (2.0*x*y*b + (y**2 - x**2)*sqrt(val))/(x**2 + y**2)
if((a-temp)>0.0000001):
print "Escape is possible."
else:
print "Box cannot be dropped."