Skip to content

Instantly share code, notes, and snippets.

/dec.py Secret

Created January 1, 2018 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e00cda2d1fd6ec5a8fb727d609d19980 to your computer and use it in GitHub Desktop.
Save anonymous/e00cda2d1fd6ec5a8fb727d609d19980 to your computer and use it in GitHub Desktop.
import sys
from decimal import *
getcontext().prec = 32
def distance(fr,to):
dis_2 = (fr[0]-to[0])**2+(fr[1]-to[1])**2+(fr[2]-to[2])**2
return Decimal(str(dis_2))**Decimal('0.5')
def travel():
N = Decimal(str(int(sys.stdin.readline())))
L = []
for i in xrange(4):
L.append(map(int,sys.stdin.readline().split()))
a = distance([0,0,0],L[0])
b = distance(L[0],L[1])
c = distance(L[1],L[2])
d = distance(L[2],L[3])
if a+b+c+d <= N: return 'YES'
return 'NO'
def main():
N = int(sys.stdin.readline())
for i in xrange(N):
print travel()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment