1065번 – 한수

1

문제

https://www.acmicpc.net/problem/1065

풀이

코드

def check(n):
  if n < 100: return True
  arr = [int(i) for i in str(n)]
  diff = arr[1] - arr[0]
  for i in range(2, len(arr)):
    if (arr[i] - arr[i-1]) != diff: return False
  return True

def answer(n):
  count = 0
  for i in range(1, n+1):
    if check(i): count += 1
  return count

n = int(input())
print(answer(n))

Add Comment