1 / 3

11018: Mars Buggy Problem

11018: Mars Buggy Problem. ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11018: Mars Buggy Problem 解題者: 鍾正一 解題日期: 200 7 年 4 月 17 日 題意: 給定 N 個殖民地的經度以及緯度,接者輸入 M 組起點、終點以及每次車子可以跑的最遠距離, 每到一個殖民地,車子的油量就會捕充滿 , 利用程式判斷是否存在最短路徑,若有列出經過的路線,若無,列出最接近的距離。. Output: Scenario 1:

maleah
Download Presentation

11018: Mars Buggy Problem

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 11018: Mars Buggy Problem • ★★★☆☆ • 題組:Problem Set Archive with Online Judge • 題號: 11018: Mars Buggy Problem • 解題者:鍾正一 • 解題日期:2007年4月17日 • 題意:給定N個殖民地的經度以及緯度,接者輸入M組起點、終點以及每次車子可以跑的最遠距離,每到一個殖民地,車子的油量就會捕充滿,利用程式判斷是否存在最短路徑,若有列出經過的路線,若無,列出最接近的距離。

  2. Output: Scenario 1: ------------------------------ From Lousberg to van_den_Hoogen with range 1200 km: Lousberg at 0 km. van_de_Kieft at 1198 km. Lubbers at 2154 km. Duponselle at 3065km. van_den_Hoogen at 3969 km. ------------------------------ From Rasschaert to Ramnath with range 1000 km: No route for this range, minimum required range is 1217 km. ------------------------------ From Lubbers to van_Dijk with range 10 km: Lubbers at 0 km. van_Dijk at 5 km. ------------------------------ • 題意範例: Input: 11 Lousberg 0.500000 1.000000 Rasschaert 0.000000 0.500000 Lubbers 0.000000 1.000000 van_den_Hoogen -0.500000 1.000000 Bink 0.000000 1.500000 van_de_Kieft 0.200000 0.800000 Bronkhorst -0.300000 1.100000 van_Dijk 0.001000 1.001000 Zijlstra 0.010000 1.020000 Duponselle -0.250000 0.900000 Ramnath -0.400000 0.600000 3 Lousberg van_den_Hoogen 1200 Rasschaert Ramnath 1000 Lubbers van_Dijk 1000

  3. 解法:利用題目所給的距離計算公式 • a = haversine(lat2 - lat1) • b = cos(lat1) * cos(lat2) * haversine(lon2 - lon1) • c = 2 * atan2(sqrt(a + b), sqrt(1 - a - b)) • d = R * c • 將所有點的距離都算出來,並且把超過車子行走最大距離的路徑刪除,再找出最短的距離。 • 解法範例:無 • 討論: (1) 範圍:2<=n<=100,1<=m<=100,地名不超過128個字母 (2) 緯度+-π/2 ,經度0~2π (3)所有的距離計算後都四捨五入 (4) 時間複雜度O(n2)

More Related