All problems

Problem 539

Integer to English Words

Hard · 30 pts · String, Math, Recursion

Problem

Write a non-negative integer in English words, with each word capitalised and words separated by single spaces. Use the scale words Thousand, Million and Billion, write numbers below one hundred as one word or two words (like Twenty Three), and do not use the word And. Zero is written as Zero. Process the number in groups of three digits from the right, convert each non-zero group, and attach its scale word.

Input

A single integer X.

Output

Print X in English words.

Constraints

0 <= X <= 2147483647

Example input

12345

Example output

Twelve Thousand Three Hundred Forty Five

Explanation

12345 splits into the groups 12 and 345. 12 thousand is Twelve Thousand, and 345 is Three Hundred Forty Five, so the answer is Twelve Thousand Three Hundred Forty Five.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Letter Combinations of a Phone Number Next: Minimum Deletions to Make String Balanced