Logo
(追記) (追記ここまで)

32012번 - Talking About Numbers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB19111161.111%

문제

The programmers of a TTS (text-to-speech) program have discovered that their product does a poor job of reading numbers written in conventional numeric form. Currently, it just announces each digit in the number, one after the other, which gets confusing to the listener after a few digits have gone by.

They would prefer to have a more natural reading of numbers, and one of them has suggested that, if they convert numeric strings into the appropriate text equivalent, e.g., convert "1023ドル$" into "one thousand and twenty three", then their speech engine will be able to handle the reading with no further modification.

Write a program to carry out the transformation of non-negative integers into conventional English wording:

  • English has unique names for the numbers 0ドル$-19ドル$: "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen".
  • The subsequent multiples of 10ドル$ are named "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety".
  • The combination of one of those multiples of ten with a digit 1ドル$-9ドル$ is always hyphenated: e.g., 31ドル \Rightarrow$ "thirty-one", 77ドル \Rightarrow$ "seventy-seven".
  • Multiples of 100ドル$ are counted 1ドル$-9ドル$ and set off from any following non-zero digits by 'and': e.g., 200ドル \Rightarrow$ "two hundred", 412ドル \Rightarrow$ "four hundred and twelve", 777ドル \Rightarrow$ "seven hundred and seventy-seven".
  • Thousands and millions are counted off using the above rules to form numbers 1ドル$-999ドル,ドル and are set off from any non-zero remainder by a comma: e.g., 1ドル,253円,101円 \Rightarrow$ "one million, two hundred and fifty-three thousand, one hundred and one".
  • If a number with a non-empty thousands or millions component is followed by a remainder of 1ドル$-99ドル,ドル then instead of a comma the parts are separated by "and": e.g., 1ドル,000円,011円 \Rightarrow$ "one million and eleven", 20ドル,222円,043円 \Rightarrow$ "twenty million, two hundred and twenty-two thousand and forty-three".

입력

Input will consist of one or more datasets. Each dataset will consist of a single line containing a non-negative integer in the range 0ドル\ldots 999,999円,999円$. Although we have used commas within digit strings for clarity in this problem description, there will be no commas in the input. There will be no leading zeros on positive input numbers.

A line with a negative value signals the end of input.

출력

For each dataset, print a single line containing the spelled-out equivalent of the number, according to the rules above.

Formatting requirements:

  • The output must be left-justified.
  • All alphabetic characters must be in lower-case.
  • Exactly one blank must separate adjacent words, except when a hyphen or comma is called for.
  • When a comma is used, it must be followed by exactly one blank.
  • When a hyphen is used, no blank space appears to either side of the hyphen.

제한

예제 입력 1

1
222143
1000001
-1

예제 출력 1

one
two hundred and twenty-two thousand, one hundred and forty-three
one million and one

힌트

출처

ICPC > Regionals > North America > Mid-Atlantic Regional > 2015 Mid-Atlantic Regional Programming Contest G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /