丑数
丑数
http://www.nowcoder.com/questionTerminal/6aa9e04fc3794f68acf8778237ba065b
# -*- coding:utf-8 -*- class Solution: def GetUglyNumber_Solution(self, index): if index == 0: return 0 list_2 = [1] list_3 = [1] list_5 = [1] cur_min = None for i in range(index): cur_min = min(list_2[0], list_3[0], list_5[0]) for l in [list_2, list_3, list_5]: if l[0] == cur_min: l.pop(0) list_2.append(cur_min * 2) list_3.append(cur_min * 3) list_5.append(cur_min * 5) return cur_min