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, and n does not exceed 1690.

 class Solution:

     def nthUglyNumber(self, n):
"""
:type n: int
:rtype: int
"""
l= []
l.append(1)
t2,t3,t5=0,0,0
mins = 0
while len(l)<n:
mins = min(l[t2]*2,l[t3]*3,l[t5]*5)
l.append(mins)
if(mins == l[t2]*2):
t2+=1
if(mins == l[t3]*3):
t3+=1
if(mins == l[t5]*5):
t5+=1
return l[-1]

最新文章

  1. FCM聚类算法介绍
  2. session过期返回登录页面跳出frame
  3. jquery.validate:
  4. C#之XMAL与WPF
  5. aspx页面Page_Load和aspx页面上控件Page_Load事件执行顺序
  6. Python入门(二,基础)
  7. 功能:使用QQ号登陆,并加上微信和短信提醒,是否增量备份可选,阿里大鱼短信发送开发与测试,聚合数据(用JSON发短信,比较清楚)
  8. 关于Windows高DPI的一些简单总结(Window上一般默认是96 dpi 作为100% 的缩放比率)
  9. javascript requestAnimationFarme
  10. Oracle timestamp类型转换成date类型
  11. Signed Distance Field Shadow in Unity
  12. [EOJ Monthly 2018.10][C. 痛苦的 01 矩阵]
  13. vue插件 使用use注册Vue全局组件和全局指令
  14. vue 路由传参 params 与 query两种方式的区别
  15. protobuf for java
  16. python---redis缓存页面前戏之剖析render源码
  17. linux centos挂载数据盘教程
  18. 五种I/O模型和select函数简介
  19. java 多线程 2 Thread中start()和run()的区别
  20. 各种常用的JSON接口

热门文章

  1. Mac 安装Bower
  2. Shell脚本编程与文件系统修复
  3. 模拟http请求 带 chunked解析办法一
  4. ISP (互联网服务提供商)
  5. c#基础 第四讲
  6. GNU Libtool
  7. linux tree命令以树形结构显示文件目录结构
  8. 每天一個Linux指令- chmod指令
  9. 【opencv】 solvepnp 和 solvepnpRansac 求解 【空间三维坐标系 到 图像二维坐标系】的 三维旋转R 和 三维平移 T 【opencv2使用solvepnp求解rt不准的问题】
  10. windows系统的对象管理