535 Globetrotter - UVa Online Judge
535 Globetrotter - UVa Online Judge
535 Globetrotter - UVa Online Judge
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>535</strong><strong>Globetrotter</strong> Zurich,Philadelphia,SanJose,Atlanta,...from1999ontheContestFinalsevenwillbeonadierent ACMContestProblemsArchive AsamemberofanACMprogrammingteamyou'llsoonndyourselfalwaystravelingaroundtheworld: continenteachyear,soonedayyoumightgettoJapanorAustralia. UniversityofValladolid(SPAIN)<br />
sake,yourjobistowriteaprogramtocomputethegeographicaldistancebetweentwogivenlocations distancebetweenAandBisthelengthofthegeodeticlinesegmentconnectingAandB. ontheEarth'ssurface. Atthecontestsiteitwouldbeinterestingtoknowhowmanymilesyouareawayfromhome.Forthis WeassumethattheEarthisaperfectspherewitharadiusofexactly6378km.Thegeographical<br />
Theinputlewillconsistoftwoparts:alistofcitiesandalistofqueries. InputSpecication entirelyinthesurfaceofthesphere. Thegeodeticlinesegmentbetweentwopointsonasphereistheshortestconnectingcurvelying<br />
CityList Thevalueofpi()isapproximately3.1415926<strong>535</strong>89793.<br />
realnumberslatiandlongi,representingthecityname,itslatitudeanditslongitude,respectively. and+180wherenegativenumbersdenotelocationswestofthemeridianandpositivenumbersdenote latitudewillbebetween-90(SouthPole)and+90(NorthPole).Thelongitudewillbebetween-180 Thecitylistconsistsofupto100lines,onelinepercity.Eachlinewillcontainastringciandtwo<br />
QueryList locationseastofthemeridian.(ThemeridianpassesthroughGreenwich,London.) Thecitynamewillbeshorterthan30charactersandwillnotcontainwhite-spacecharacters.The EachlinewillcontaintwocitynamesAandB. Thecitylistwillbeterminatedbyalineconsistingofasingle\#".<br />
Foreachquery,printalinesaying\A-B"whereAandBarereplacedbythecitynames.Thenprint roundedtothenearestinteger. alinesaying\xkm"wherexisreplacedbythegeographicaldistance(inkm)betweenthetwocities, OutputSpecication Ifoneofthecitiesinthequerydidn'toccurinthecitylist,printalinesaying\Unknown"instead. Thequerylistwillbeterminatedbytheline\##".
Freiburg47.7009.500 Ulm48.70010.500 Philadelphia39.883-75.250 SampleInput ACMContestProblemsArchive UniversityofValladolid(SPAIN)<br />
SanJose37.366-121.933 NorthPole900 SouthPole-900<br />
UlmLasVegas #UlmPhiladelphia UlmUlm UlmNorthPole FreiburgSanJose UlmFreiburg SanJosePhiladelphia UlmSanJose<br />
UlmSouthPole FreiburgPhiladelphia<br />
Ulm-Philadelphia 6536km Ulm-SanJose NorthPoleSouthPole<br />
9367km ##<br />
Freiburg-Philadelphia 6519km SampleOutput<br />
9412km Ulm-Freiburg 134km SanJose-Philadelphia Freiburg-SanJose 4023km Ulm-LasVegas Unknown Ulm-Ulm<br />
Ulm-NorthPole 4597km Ulm-SouthPole 15440km NorthPole-SouthPole 20037km