i,j,k = [int(x) for x in input().strip().split(' ')] cnt = 0 for n in range(i,j): diff = abs(n - int(str(n)[::-1])) % k if diff == 0: cnt += 1 print(cnt)
조금더 일반적인(?) 방법
def bueatiful_days2(): i,j,k = [int(x) for x in input().strip().split(' ')] res = sum(1 for x in range(i,j) if abs(int(str(x)[::-1])-x) % k == 0) print(res)
댓글 없음:
댓글 쓰기