博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1058 Humble Numbers (DP)
阅读量:7021 次
发布时间:2019-06-28

本文共 1587 字,大约阅读时间需要 5 分钟。

Humble Numbers

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 15978    Accepted Submission(s): 6915

Problem Description
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers. 
Write a program to find and print the nth element in this sequence
 

 

Input
The input consists of one or more test cases. Each test case consists of one integer n with 1 <= n <= 5842. Input is terminated by a value of zero (0) for n.
 

 

Output
For each test case, print one line saying "The nth humble number is number.". Depending on the value of n, the correct suffix "st", "nd", "rd", or "th" for the ordinal number nth has to be used like it is shown in the sample output.
 

 

Sample Input
1
2
3
4
11
12
13
21
22
23
100
1000
5842
0
 

 

Sample Output
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.
 
 

 

Source
 

 

Recommend
JGShining   |   We have carefully selected several similar problems for you:            
 

简单DP,有点巧妙:

1 //93 MS    228 KB    GNU C++ 2 #include
3 int ans[6000]; 4 inline int Min(int a,int b) 5 { 6 return a

 

转载于:https://www.cnblogs.com/GO-NO-1/p/3684865.html

你可能感兴趣的文章
Since150910
查看>>
汇编第五章总结
查看>>
HTML常见元素集锦
查看>>
[翻译文章]javascript的对象(how javascript objects works?)
查看>>
关于登录与购买和数据模块
查看>>
第 3 章 镜像 - 012 - 构建镜像
查看>>
dp【多进程类】
查看>>
简易抽取
查看>>
js转html实体
查看>>
django框架数据库相关操作
查看>>
FreeSWITCH增加iLBC编码
查看>>
PostgreSQL在线安装
查看>>
iOS中有两种支持机制:Notification和KVO(Key-Value Observing)
查看>>
准备从头复习算法
查看>>
SQL SERVER发布与订阅
查看>>
oracle行转列遇到的一个问题
查看>>
Fiddler
查看>>
Spring Cloud 之 服务注册与发现
查看>>
集合 小结
查看>>
confluence
查看>>