Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Text;
- namespace N_redica
- {
- class Program
- {
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- static void Main(string[] args)
- {
- string LON1 = Console.ReadLine();
- string LAT1 = Console.ReadLine();
- string LON = LON1.Replace(',', '.');
- string LAT = LAT1.Replace(',', '.');
- NumberFormatInfo provider = new NumberFormatInfo();
- provider.NumberDecimalSeparator = ".";
- provider.NumberGroupSeparator = ",";
- double longtitudeA = Convert.ToDouble(LON,provider);
- double latitudeA = Convert.ToDouble(LAT,provider);
- // Console.WriteLine(longtitudeA);
- int N = int.Parse(Console.ReadLine());
- Dictionary<string, double> defib = new Dictionary<string, double>();
- for (int i = 0; i < N; i++)
- {
- string DEFIB = Console.ReadLine();
- string[] input = DEFIB.Split(";");
- string name = input[1];
- string longt = input[input.Length - 2];
- LON = longt.Replace(',', '.');
- double longtitudeB = Convert.ToDouble(LON, provider);
- string lat = input[input.Length - 1];
- LAT = lat.Replace(',', '.');
- double latitudeB = Convert.ToDouble(LAT, provider);
- double x1 = longtitudeB - 0.00000000000000000000000000001 - longtitudeA;
- // Console.WriteLine(x1);
- double x=x1* Math.Cos((latitudeA - latitudeB) / 2);
- double y = latitudeB - latitudeA;
- // Console.WriteLine(y);
- double distance = Math.Sqrt(x*x + y*y) * 6371.0;
- defib[name] = distance;
- }
- double shortestDistance = double.MaxValue;
- string closestName = "";
- foreach (KeyValuePair<string, double> pair in defib)
- {
- if (pair.Value < shortestDistance)
- {
- shortestDistance = pair.Value;
- closestName = pair.Key;
- }
- }
- Console.WriteLine(closestName);
- Console.ReadLine();
- }
- }
- }
- /*input
- 3,879483
- 43,608177
- 3
- 1;Maison de la Prevention Sante;6 rue Maguelone 340000 Montpellier;;3,87952263361082;43,6071285339217
- 2;Hotel de Ville;1 place Georges Freche 34267 Montpellier;;3,89652239197876;43,5987299452849
- 3;Zoo de Lunaret;50 avenue Agropolis 34090 Mtp;;3,87388031141133;43,6395872778854
- output
- Maison de la Prevention Sante
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement