백준 9228번: Check Digits #Python

ColorlessDia·2026년 2월 20일

algorithm/baekjoon

목록 보기
825/836
import sys

input = sys.stdin.readline

while True:
    line = input().rstrip()

    if line == '#':
        break

    total = 0

    for i, d in enumerate(reversed(line), 2):
        total += i * int(d)
    
    check_digit = 11 - (total % 11)

    if check_digit == 10:
        print(f'{line} -> Rejected')
    elif check_digit == 11:
        print(f'{line} -> 0')
    else:
        print(f'{line} -> {check_digit}')

0개의 댓글