【leetcode❤python】263. Ugly Number

class Solution(object):
    def isUgly(self, num):
        if num<=0:return False
        comlist=[2,3,5];modflag=0
        
        while True:

            if num==1:break
            for value in comlist:
                tuple=divmod(num,value)
                if tuple[1]==0:
                    modflag=1;num=tuple[0]
                    break
            if modflag==0:return False
            modflag=0
        
        return True
                    

sol=Solution()
print sol.isUgly(1)

上一篇:Codeforces Round #102 (Div. 2) 题解


下一篇:centos7安装rabbitmq 总结