Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const LON = +readline().replace(",", ".");
- const LAT = +readline().replace(",", ".");
- const N = parseInt(readline());
- const defibNames = []
- const allDistances = []
- for (let i = 0; i < N; i++) {
- const DEFIB = readline();
- const data = DEFIB.split(";")
- defibNames.push(data[1])
- const defibLON = +data[data.length - 1].replace(",", ".")
- const defibLAT = +data[data.length - 2].replace(",", ".")
- const x = (LON - defibLON) * (Math.cos(defibLAT + LAT) / 2)
- const y = (LAT - defibLAT)
- const d = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) * 6371
- allDistances.push(d)
- }
- console.log(defibNames[allDistances.indexOf(Math.min(...allDistances))]);
- // Write an answer using console.log()
- // To debug: console.error('Debug messages...');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement