#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param index int整型
# @return int整型
#
class Solution:
def GetUglyNumber_Solution(self , index: int) -> int:
# write code here
# res=[1,2,3,4,5,6,8,9,10,12]
res=[1]
a=b=c=0
while len(res)<index:
v=min(res[a]*2,res[b]*3,res[c]*5)
res.append(v)
if res[a]*2==v:
a+=1
if res[b]*3==v:
b+=1
if res[c]*5==v:
c+=1
return res[index-1] if index!=0 else 0

京公网安备 11010502036488号