1. 문제 설명

1

2. 문제 분석

EOF를 받을 때까지 테스트 케이스를 입력받을 때에는 try except를 사용하자.

3. 나의 풀이

import sys

while True:
    try:
        n = int(sys.stdin.readline().rstrip())
    except:
        break

    if n == 1:
        print(1)
        continue
    base = 1
    length = 1
    while True:
        base = base * 10 + 1
        # 11, 111, 1111...
        length += 1
        if base % n == 0:
            # base가 n의 배수이면
            print(length)
            # base의 자릿수를 출력
            break
profile
JUST DO IT

0개의 댓글

Powered by GraphCDN, the GraphQL CDN