- 浏览: 35935 次
文章分类
- 全部博客 (41)
- 卧鸟个去 (2)
- Transform (2)
- Mathmatic (9)
- Plant-Tree (7)
- Data-Struct (12)
- Red-Black-Tree (1)
- Radix-Tree (1)
- Trie (2)
- String (4)
- BST (2)
- Amazing-Union-Find-Set (1)
- HDU (27)
- OJ (32)
- BFS (3)
- Pretty-Suffix-Array (2)
- POJ (6)
- Graceful-Segment-Tree (2)
- Geometry (6)
- Priority-Queue (2)
- Dynamic-Programing (1)
- DP (3)
- LCS (1)
- Convex-Hull (2)
- Triangulation (1)
- DFS (3)
- Combinatorial-Mathematics (2)
- Big-Number (1)
- Statistic (3)
- STL (1)
- Shortest-Path (3)
- ZOJ (1)
- Leftist-Tree (1)
- Prime (1)
- Binary-Index-Tree (1)
- (1)
- Stack (1)
- SPFA (0)
- CRT (1)
Humble Numbers
Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6116Accepted Submission(s): 2652
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
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
一睇就知道系水题………………
不过我WA左11次,我反复改核心算法,都系WA,其实问题出系输出,大家有无发觉11,12,13做结尾既时候唔会分st,nd,rd,我实在唔知道呢样野。
核心算法就系每次都将当前位置既数乘以四个因子,选出最小者,作为下一个最小值,其实就系维护最小值问题,自然就会捻到优先队列,防重复就用映射。
贴代码:
4313585 | 2011-08-02 15:50:09 | Accepted | 1058 | 78MS | 560K | 840 B | C++ | 10SGetEternal{(。)(。)}! |
无文化,真可怕…………
发表评论
-
HDU 1370 Biorhythms
2011-08-03 10:27 1149Biorhythms Time Limit: 2000/10 ... -
HDU 1075 What Are You Talking About
2011-08-04 11:00 831What Are You Talking About Tim ... -
HDU 2095 find your present (2)
2011-08-02 16:13 763find your present (2) Time Lim ... -
HDU 1022 Train Problem I
2011-08-02 21:00 994Train Problem I Time Limit: 20 ... -
2142 HDU box
2011-08-02 21:21 733box Time Limit: 3000/1000 MS ( ... -
HDU 2151 Worm
2011-08-01 20:48 784Worm Time Limit: 1000/1000 MS ... -
HDU 2722 Here We Go(relians) Again
2011-08-02 00:06 968Here We Go(relians) Again Time ... -
HDU 3791 二叉搜索树
2011-08-02 14:26 1160二叉搜索树 Time Limit: 20 ... -
PKU 2352 Stars
2011-07-31 21:47 984Stars Time Limit: 1000MS ... -
PKU 2774 Long Long Message
2011-07-31 21:26 861Long Long Message Time Li ... -
PKU 2777 Count Color
2011-07-31 21:31 767Count Color Time Limit: 1 ... -
HDU 2098 分拆素数和
2011-07-31 21:08 1013分拆素数和 Time Limit: 1000/1000 MS ... -
ZOJ 3512 Financial Fraud .
2011-07-31 20:49 1227Financial Fraud Time Limit: 3 ... -
HDU 1798 Tell me the area .
2011-07-31 20:47 1069Tell me the area Time Limit: 3 ... -
HDU 2962 Trucking .
2011-07-31 20:46 638Trucking Time Limit: 20000/100 ... -
HDU 1596 find the safest road .
2011-07-31 20:45 569find the safest road Time Limi ... -
HDU 2553 N皇后问题 .
2011-07-31 20:20 658N皇后问题 Time Limit: 2000/1000 MS ... -
HDU 1392 Surround the Trees .
2011-07-31 20:19 756Surround the Trees Time Limit: ... -
HDU 1234 开门人和关门人 .
2011-07-31 20:17 639开门人和关门人 Time Limit: 2000/1000 ... -
HDU 1316 How Many Fibs? .
2011-07-31 20:15 941How Many Fibs? Time Limit: 200 ...
相关推荐
HDU的1250,主要是利用高精度加法,但是代码有点繁琐,效率不是很高
HDU1059的代码
杭电ACMhdu1163
hdu1001解题报告
hdu 1574 passed sorce
HDU的一题........HDU DP动态规
hdu acm 教案 搜索入门 hdu acm 教案 搜索入门
hdu2101AC代码
搜索 dfs 解题代码 hdu1241
hdu acm 教案 动态规划(1) hdu acm 教案 动态规划(1)
hdu 5007 Post Robot 字符串枚举。 暴力一下就可以了。
ACM HDU题目分类,我自己总结的大概只有十来个吧
HDU最全ac代码
hdu 1166线段树代码
hdu动态规划算法集锦
hdu题目分类
自己做的HDU ACM已经AC的题目
hdu-acm源代码(上百题)hdu-acm源代码、hdu-acm源代码hdu-acm源代码
HDU图论题目分类
Hdu 1237 解题代码