eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

PSU Campuses

PSU Campuses

Prince of Songkla University or PSU has \textbf{5} campuses in the South of Thailand. These campuses are Hatyai(H), Pattani(P), Suratthani(S), Phuket(K) and Trang(T). The distances between these campuses are shown in the table below. When the President of PSU goes on mission in different campuses, he or she may want to know the total distance of the mission. The mission always starts from Hatyai campus and when the mission ends the president will always go back directly to Hatyai campus. Given a list of campuses of a mission, your task is to write a program to calculate the total distance of the mission. \InputFile The first line contains an integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{100}) which determines the number of missions. The following \textbf{n} lines contain a description of each mission. A mission is described by a string comprising only characters \textbf{H}, \textbf{P}, \textbf{S}, \textbf{K} and \textbf{T }which refer to PSU campuses. The president visits the campuses in the order indicated in that string. Since Hatyai campus is always the starting point and also the end point of a mission, we will not mention \textbf{H} at the beginning or the end of the string. However, \textbf{H} can be an intermediate campus in a mission. A mission string may contain at most \textbf{10 }characters. \OutputFile For each mission (\textit{mission_i}), print out in a line, "\textbf{Case i: }" followed by the total distance (km), exactly as shown in the sample output.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
4
TSK
PHT
PSKT
KT
Вихідні дані #1
Case 1: 1127
Case 2: 502
Case 3: 1258
Case 4: 926
Джерело ACM-ICPC Asia Phuket Regional Programming Contest 2013, Practice Session, 21 November 2013