[백준 1769][Python] 3의 배수

봉글렛·2022년 12월 24일

백준

목록 보기
2/55

문제 링크 https://www.acmicpc.net/problem/1769

결과값에서 오래걸렸다... 문제를 잘 읽자

풀이

x = input()
num = 0
while True:
    if len(x) > 1:
        num += 1
        n = 0
        for i in x:
            n += int(i)
        x = str(n)
    else:
        if int(x) % 3 == 0:
            print(num)
            print('YES')
        else:
            print(num)
            print('NO')
        break
profile
어쩌다 개발자 (할 수 있을 때까지!!!!)

0개의 댓글