问题 H: Humble Numbers 第n个丑数 [2+]

传统题
1.000s 时间限制
128MB 内存限制
28 提交
5 解决

【题目描述】
只有素数因子为2、3、5或7的数称为丑数。序列1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27。。。显示了前20个丑数。

编写一个程序,按此顺序查找并打印第n个丑数。


输入
输入由一个或多个测试用例组成。每个测试用例由一个整数n组成,其中1<=n<=5842。n的输入值以零(0)终止。


输出

对于每个测试用例,打印一行“The nth humble number is number.”。根据n的值,必须使用序号n的正确后缀“st”、“nd”、“rd”或“th”,就像样本输出中显示的那样。


输入样例
1 2 3 4 11 12 13 21 22 23 100 1000 5842 0 


输出样例
The 1st humble number is 1. 
The 2nd humble number is 2. 
The 3rd humble number is 3. 
The 4th humble number is 4. 
The 11th humble number is 12. 
The 12th humble number is 14. 
The 13th humble number is 15. 
The 21st humble number is 28. 
The 22nd humble number is 30. 
The 23rd humble number is 32. 
The 100th humble number is 450. 
The 1000th humble number is 385875. 
The 5842nd humble number is 2000000000. 




 资料来源:1996年乌尔姆大学地方竞赛
【样例输入】复制
1308
781
4901
3402
1256
0
【样例输出】 复制
The 1308th humble number is 1119744.
The 781st humble number is 153090.
The 4901st humble number is 714256704.
The 3402nd humble number is 96018048.
The 1256th humble number is 944784.

题目类型~

基础算法-枚举