2336. Give Me an E

单点时限: 2.0 sec

内存限制: 256 MB

Everyone knows that the letter “E” is the most frequent letter in the English language. In fact, there are one hundred sixteen E’s on this very page … no, make that one hundred twenty one. Indeed, when spelling out integers it is interesting to see which ones do NOT use the letter “E”. For example 6030 (six thousand thirty) doesn’t. Nor does 4002064 (four million two thousand sixty four). It turns out that 6030 is the 64th positive integer that does not use an “E” when spelled out and 4002064 is the 838th such number. Your job is to find the n-th such number.

Note: 1,001,001,001,001,001,001,001,001,000 is “one octillion, one septillion, one sextillion, one quintil- lion, one quadrillion, one trillion, one billion, one million, one thousand”. (Whew!)

输入格式

The input file will consist of multiple test cases. Each input case will consist of one positive integer n (less than 231) on a line. A 0 indicates end-of-input. (There will be no commas in the input.)

输出格式

For each input n you will print, with appropriate commas, the n-th positive integer whose spelling does not use an “E”. You may assume that all answers are less than 1028.

样例

Input
1
10
838
0
Output
2
44
4,002,064

6 人解决,7 人已尝试。

9 份提交通过,共有 20 份提交。

6.4 EMB 奖励。

创建: 15 年,11 月前.

修改: 6 年,10 月前.

最后提交: 3 年,6 月前.

来源: 2007 East Central Regional Contest

题目标签