U E D R , A S I H C RSS

Ugly Numbers/승한

No difference found



  • 잘못된 예-_-
  • 3분이 넘어가도 답이 안 나오는 소스-_- 다시 짜야죠ㅋㅋㅋ

~cpp
def divisor(target, div):
    if target < div:
        return target
    while target % div == 0:
        target /= div
    return target

def isUgly(target):
    target = divisor(target, 2)
    target = divisor(target, 5)
    target = divisor(target, 3)    
    if target != 1:
        return False
    return True

n = 1
count = 1;
while count != 1500:
    if isUgly(n):
        print n , count
        count+=1
    n+=1
print n-1

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:20
Processing time 0.0266 sec