알고리즘

[백준] 1436번(python 파이썬)

changha. 2022. 6. 26. 22:40
n = int(input())
cnt = 0
idx = 666
while True:
    if '666' in str(idx):
        cnt += 1
    
    if cnt == n:
        print(idx)
        break
    idx += 1

 

처음 접근 했을 때 

666 앞에 n - 1만큼 붙이면 되겠다고 생각 함 

오류..

7.  6660 

8.  6661

9.  6662

....

위처럼 뒤에 6 아닌 수 가능함 

666 부터 시작해서 cnt == n 일때까지 반복