当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3781:Aronson

题目描述
Aronson's sequence ak is a sequence of integers defined by the sentence "t is the first, fourth, eleventh, ... letter of this sentence.", where the ... are filled in appropriately so that the sentence makes sense. The first few values are 1, 4, 11, 16, 24, 29, 33, 35, 39, .... Note the non-letter characters and spaces are not considered in the formulation of the sequence. When k <= 100000, it turns out that ak <= 1000000.

To formulate the sequence, you must be able to write the ordinal numbers in English. The ordinal numbers are first, second, third, ..., while the cardinal numbers are one, two, three, .... It is easiest to define the ordinals in terms of the cardinals, so we describe these first.

A cardinal number less than twenty is written directly from the first two columns of table 1 (3->three, 17->seventeen, etc.). A cardinal number greater than or equal to twenty, but less than one hundred is written as the tens part, along with a nonzero ones part (40-> forty, 56->fifty six, etc). A cardinal number greater than or equal to one hundred, but less than one thousand, is written as the hundreds part, along with a nonzero remainder (100->one hundred, 117->one hundred seventeen, 640->six hundred forty, 999->nine hundred ninety nine). A cardinal number greater than or equal to one thousand, but less than one million, is written as the thousands part, along with a nonzero remainder (12345->twelve thousand three hundred forty five). An ordinal number is written as a cardinal number, but with the last word ordinalized using the columns three and four of table 1.

Some example ordinal numbers are 3rd->third, 56th->fifty sixth, 100th->one hundredth, and 12345th->twelve thousand three hundred forty fifth.
输入解释
The input consists of a number of cases. Each case is specified by a positive integer k on one line (1 <= k <= 100000). The sequence of k values will be non-decreasing. The input is terminated by a line containing a single 0.
输出解释
For each k, print the value of ak on one line. The values of ak will be at most 1000000.
输入样例
1
3
9
0
输出样例
1
11
39

Table 1
n      cardinal     nth   ordinal
1      one          1st   first
2      two          2nd   second
3      three        3rd   third
4      four         4th   fourth
5      five         5th   fifth
6      six          6th   sixth
7      seven        7th   seventh
8      eight        8th   eighth
9      nine         9th   ninth
10     ten          10th  tenth
11     eleven       11th  eleventh
12     twelve       12th  twelfth
13     thirteen     13th  thirteenth
14     fourteen     14th  fourteenth
15     fifteen      15th  fifteenth
16     sixteen      16th  sixteenth
17     seventeen    17th  seventeenth
18     eighteen     18th  eighteenth
19     nineteen     19th  nineteenth
20     twenty       20th  twentieth
30     thirty       30th  thirtieth
40     forty        40th  fortieth
50     fifty        50th  fiftieth
60     sixty        60th  sixtieth
70     seventy      70th  seventieth
80     eighty       80th  eightieth
90     ninety       90th  ninetieth
100    hundred      100th  hundredth
1000   thousand     1000th  thousandth
提示
来自杭电HDUOJ的附加信息
Recommend notonlysuccess

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3781

最后修改于 2020-10-25T23:06:58+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)