136 - Ugly Numbers
Time limit: 3.000 seconds
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...
shows the first 11 ugly numbers. By convention, 1 is included.
Write a program to find and print the 1500'th ugly number.
Input and Output
There is no input to this program. Output should consist of a single line as shown below, with <number> replaced by the number computed.
Sample output
The 1500'th ugly number is <number>.
可以用暴力先把答案算出来。
或者,用2,3,5来拼凑。
完整代码:
/*0.009s*/
#include <cstdio>
int main(void)
{
puts("The 1500'th ugly number is 859963392.");
return 0;
}

本文介绍了一种高效的方法来找到序列中的第1500个丑数,丑数是指仅包含质因数2、3和5的整数。通过直接计算给出答案为859963392,并提供了完整的C语言代码实现。
497

被折叠的 条评论
为什么被折叠?



