leetcode 264. Ugly Number II
傳送門
264. Ugly Number II
? QuestionEditorial Solution ?My Submissions- Total Accepted:?36259
- Total Submissions:?122710
- Difficulty:?Medium
?
Write a program to find the?n-th ugly number.
Ugly numbers are positive numbers whose prime factors only include?2, 3, 5. For example,?1, 2, 3, 4, 5, 6, 8, 9, 10, 12?is the sequence of the first?10?ugly numbers.
Note that?1?is typically treated as an ugly number.
Show Hint?Credits:
Special thanks to?@jianchao.li.fighter?for adding this problem and creating all test cases.
?
Subscribe?to see which companies asked this question
Hide Tags ?Dynamic Programming?Heap?Math Show Similar Problems 題解轉自: http://blog.csdn.net/u014673347/article/details/47782645題意:?
寫一個程序去查找第n個丑數(shù)。丑數(shù)的定義是該數(shù)字只能有2,3,5這樣的因子。1作為第一個丑數(shù)。?
思路:?
我們知道丑數(shù)是由某個丑數(shù)乘上2或者3或者5得來。而且初始化時第一個丑數(shù)是1。
以上。?
?
轉載于:https://www.cnblogs.com/njczy2010/p/5708377.html
總結
以上是生活随笔為你收集整理的leetcode 264. Ugly Number II的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 以用户体验为导向的设计表现
- 下一篇: tomcat下manager配置