Editorial for Plus One


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: wadeyao

T = int(input())
for t in range(1,T+1):
    digits = input().split()
    digits = [int(s) for s in digits]
    finished = False
    for i in range(len(digits)-1, -1, -1):
        if digits[i] != 9:
            finished = True
            digits[i] += 1
            break
        else:
            digits[i] = 0
    if not finished:
        digits = [1] + digits

    print(f'Case #{t}: {digits}')

Comments

There are no comments at the moment.