Advertisement
Guest User

Untitled

a guest
May 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. import sys
  2. import math
  3.  
  4. # Auto-generated code below aims at helping you parse
  5. # the standard input according to the problem statement.
  6.  
  7. _id = []
  8. _lon = {}
  9. _lat = {}
  10. _adress = {}
  11.  
  12. def d(a,b):
  13.     x = (_lon[b]-_lon[a])*math.cos((_lat[a]+_lat[b])/2)
  14.     y = _lat[b]-_lat[a]
  15.     return math.sqrt(math.pow(x,2)+math.pow(y,2))*6371
  16.  
  17. lon = input()
  18. lat = input()
  19. n = int(input())
  20.  
  21. _lon[0] = math.radians(float(lon.replace(",",".")))
  22. _lat[0] = math.radians(float(lat.replace(",",".")))
  23.  
  24. for i in range(n):
  25.     defib = input()
  26.     #print(defib.split(";"), file=sys.stderr)
  27.     _d = defib.split(";")
  28.     id = int(_d[0])
  29.     _id.append(id)
  30.     _adress[id] = _d[1]
  31.     _lon[id] = math.radians(float(_d[4].replace(",",".")))
  32.     _lat[id] = math.radians(float(_d[5].replace(",",".")))
  33.  
  34.  
  35. mem = 1
  36. for id in _id:
  37.     if(d(0, id) < d(0, mem)):
  38.         mem = id
  39. # Write an action using print
  40. # To debug: print("Debug messages...", file=sys.stderr)
  41.  
  42. print(_adress[mem])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement