Aozzi

Untitled

Oct 17th, 2021
1,015
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. lon = float(input().replace(',', '.'))
  8. lat = float(input().replace(',', '.'))
  9. n = int(input())
  10. closestDist = 99999999999999999999999999999999
  11. closestName = ''
  12. for i in range(n):
  13.     defib = input().replace(',', '.').split(';')
  14.     x = (lon - float(defib[4]))*math.cos((lat + float(defib[5]))/2)
  15.     y = float(defib[5]) - lat
  16.     d = math.sqrt(x*x + y*y) * 6371
  17.     if d < closestDist:
  18.         closestDist = d
  19.         closestName = defib[1]
  20.  
  21. # Write an answer using print
  22. # To debug: print("Debug messages...", file=sys.stderr, flush=True)
  23.  
  24. print(closestName)
  25.  
RAW Paste Data