백준 1436 - 영화감독 숌 (파이썬)

Updated:

Answer

N = int(input())
front = 0
back = 0
fronttemp = 0
backlength = 0
backlimit = 0
pos = 0
state = 'front'

for _ in range(N-1):
    if state == 'front':
        front += 1
        print(front)
        pos = str(front * 100 + 66).find('666')
        if pos != -1 :
            state = 'back'
            backlength = len(str(front)) - pos
            backlimit = 10 ** backlength
            fronttemp = front // backlimit
            back = 0
    else:
        back += 1
        print(back)
        if back >= backlimit:
            state = 'front'
            front += 1

if state == 'front':
    print(front * 1000 + 666)
else:
    print((fronttemp * 1000 + 666) * backlimit + back)

Categories:

Updated: