알고리즘 문제풀이

백준 1284.집주소 Python 브론즈3

아크몽 2024. 2. 17. 22:49

 

while True:
    N = input()
    if N == '0': # 바로 나가기
        break
    cnt = 1 # 처음 한 칸
    for i in N:
        if i == '1':
            cnt += 3
        elif i == '0':
            cnt += 5
        else:
            cnt += 4
    print(cnt)