題目描述
把正整數用英文拼寫出來,並統計其中英文字母的個數(空白與連字號 - 都不計入)。拼寫規則如下:
- 到 :
one two three four five six seven eight nine - 到 :
ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen - 到 :十位用
twenty thirty forty fifty sixty seventy eighty ninety,若個位不為 ,再接上個位的拼寫(中間用連字號,例如forty-two) - 百位:數字 ()對應
h hundred,例如three hundred - 千位:數字 ()對應
t thousand,例如five thousand - 由高位到低位依序拼寫(千、百、後兩位)。只要整數 且 的後兩位數()不為 ,就要在後兩位數的拼寫前面加上單字
and。
例如 拼成 three hundred and forty-two( 個字母), 拼成 one thousand and five, 拼成 one thousand one hundred, 拼成 one hundred and fifteen。
給定 筆查詢,每筆查詢給整數 ,請計算 到 (含)的所有整數的拼寫字母數總和。
輸入格式
第一行一個整數 。 接下來 行,每行兩個整數 、。
輸出格式
輸出 行,每行一個整數,表示對應查詢的字母數總和。
範例
見下方範例輸入與輸出。
範例一: 到 為 one two three four five,共 個字母; 為 個字母; 為 one hundred( 個字母), 為 one hundred and one( 個字母),兩者總和為 。
範例測資
範例輸入 1
3 1 5 342 342 100 101
範例輸出 1
19 23 26
範例輸入 2
2 9999 9999 1 10
範例輸出 2
36 39
請先登入後再提交程式碼
討論與題解
載入討論區…