Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

注意:

Posted by chenhaifeng at 2006-10-01 17:01:22 on Problem 2247
to the problem description we need to find the numbers whose only prime factors are 2,3,5 and 7. So, we can represent the numbers as 2^i x 3^j x 5^k x 7^l. For the different values of i,j,k, and l we will get different numbers. As the maximum range is 5842 and from the last sample input and output we get that 5842nd number is 2000000000. So our maximum value will be this value. Now, by using 4 loops we can generate and preserve 
all the humble numbers in between 1 and 2000000000. After that we need to sort them. But here we must use at least O(n log n) sort. Quick Sort is enough for this problem.

Be careful about giving output.
1. After 11,12 and 13 there will be th
2. After 21....91 there will be st
3. After 22....92 there will be nd
4. After 23....93 there will be rd
5  Always after 1,2 and 3 there will be st, nd and rd respectively.

Look at the samples

Input
1
11
1001
100
99

Output
The 1st humble number is 1.
The 11th humble number is 12.
The 1001st humble number is 387072.
The 100th humble number is 450.
The 99th humble number is 448.

Note: This problem can also be solved using Dynamic Programming (refer to problem 136)


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator