Ugly Number II
Write a program to find then
-th ugly number.
Ugly numbers are positive numbers whose prime factors only include2, 3, 5
.
Example:
Note:
1
is typically treated as an ugly number.n
does not exceed 1690
分析
2,3,5 3个数字分别计个数,最后N=N2+N3+N5
loop i,每次新i值取3个数能到的最小值,然后把那个数的cnt++,每个N2,N3,N5等于是断点,决定踩哪个断点到最新的min。
Last updated