# [kattis] Babylonian Numbers >題目連結:https://open.kattis.com/problems/babylonian More than $4000$ years ago, the ancient Babylonians used a numerical system that is well known for being the first positional numerical system. In such a system, a non-negative integer is represented by a sequence of digits such that the value of a digit depends both on itself and on its position within the sequence. The Babylonians used a base-$60$ system known as sexagesimal (not unlike our own base-$10$ decimal system) where each ‘digit’ can take values between $10$ and $59$, inclusive. (The Babylonians didn’t have a digit to represent $0$; instead they would just leave the digit position empty.) Akin to the Egyptians at the time, the Babylonians carved their equations in solid clay, which allows us to read them thousands of years later. :::success 在$4000$多年前,古代巴比倫人使用了一個數字系統,這個系統以作為第一個位置數字系統而聞名。在這樣的系統中,非負整數由一個數位序列表示,這個數位序列的值既取決於它自身又取決於它在序列中的位置。巴比倫人使用了一個基數為$60$的系統,稱為“六十進制”(與我們自己的基數為$10$的十進制系統有些相似),在這個系統中,每個“數位”的值可以介於$10$到$59$之間,包括$10$和$59$。 (巴比倫人沒有一個數位來表示$0$;相反,他們會將數位位置留空。)與當時的埃及人相似,巴比倫人將他們的方程式刻在固體黏土上,這使我們能夠在數千年後閱讀它們。 ::: Your history professor, Dr. X, has asked you to decipher the Babylonian numbers he has found during a recent excavation and to convert them into our own decimal numerical system. As you are a competent translator, you have no problem deciphering the Babylonian writing, but you now need to write a program that takes the sexagesimal notation and converts it to decimal. :::success 您的歷史教授,X 博士,已要求您解讀他最近在考古中發現的巴比倫數字,並將它們轉換為我們自己的十進制數字系統。由於您是一位能幹的翻譯員,您能輕鬆解讀巴比倫文,但現在您需要編寫一個程序,將“六十進制”表示轉換為十進制。 ::: Fortunately, each clay tablet discovered by Dr. X contains numbers in a clean format where digits corresponding to consecutive powers of $60$ are separated by commas, with the most significant digit on the left. For instance, one tablet contains the Babylonian number $1,24,9$ in sexagesimal, which converts to $5049$ in decimal, since $1\times60^2+24\times60^1+9\times60^0=5049$. :::success 幸運的是,由 X 博士發現的每個黏土板都包含了以整潔格式呈現的數字,其中與$60$的連續冪對應的數位以逗號分隔,並且最重要的數位位於左側。例如,一個黏土板包含了巴比倫數字$1,24,9$,在“六十進制”中轉換為$5049$,在十進制中為$1\times60^2+24\times60^1+9\times60^0=5049$。 ::: ## Input The first line contains an integer $N$ ($1\le N\le20$), the number of test cases to follow. :::success 第一行包含一個整數$N$($1\le N\le20$),表示後面將有多少個測試案例。 ::: Each of the following $N$ lines represents a single tablet containing a number in sexagesimal format. This number is a non-empty sequence of digits separated by commas. Nonzero digits can be any integers between $1$ and $59$ (inclusive), and $0$ is represented by an empty string. The sexagesimal number does not begin with a comma, contains at least one nonzero digit, and consists of $D$ digits in total, where $1\le D\le8$. :::success 接下來的每一行代表一個單獨的黏土板,其中包含以“六十進制”格式表示的數字。這個數字是由逗號分隔的一個非空的數位序列。非零數位可以是介於$1$和$59$之間的任何整數(包括$1$和$59$),而$0$則以一個空字符串表示。這個“六十進制”數字不以逗號開頭,至少包含一個非零數位,總共包含$D$個數位,其中$1\le D\le8$。 ::: ## Output For each test case, output a line containing the decimal representation of the sexagesimal number. :::success 對於每個測試案例,輸出一行,其中包含“六十進制”數字的十進制表示。 ::: ### Sample Input 1 ``` 3 40 1,24,9 1,,, ``` ### Sample Output 1 ``` 40 5049 216000 ``` ###### 翻譯錯誤請留言告知