[알고리즘/백준] 1065번 : 한수(python)

유현민·2022년 3월 9일
0

알고리즘

목록 보기
42/253

1~99까지는 다 한수이기 때문에 더해준다.
나머지는 빼기로 비교해서 카운트 해준다.

def solution(N):
    cnt = 0
    for i in range(1, N + 1):
        han = list(map(int, str(i)))
        if i < 100:
            cnt += 1
        elif han[0] - han[1] == han[1] - han[2]:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    N = int(input())
    solution(N)
profile
smilegate megaport infra

0개의 댓글