Skip to content

Commit a818746

Browse files
committed
[BOJ] 1065 한수 (S4)
1 parent 2ea70ae commit a818746

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

심수연/11주차/260310.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# https://www.acmicpc.net/problem/1065
2+
3+
import sys
4+
input = sys.stdin.readline
5+
6+
N = int(input())
7+
count = 0
8+
9+
# 한수: 정수 N의 각 자리가 등차수열을 이루는 수. ex) 123 - 공차: 1, 357 - 공차: 2, 100 미만 - 모두 한수
10+
11+
for i in range(1, N + 1):
12+
if i < 100:
13+
count += 1 # 100 이상이면 99만큼 무조건 더해짐
14+
else: # 세자리수 (N < 1000 이므로)
15+
minus1 = int(str(N)[0]) - int(str(N)[1])
16+
minus2 = int(str(N)[1]) - int(str(N)[2])
17+
if minus1 == minus2:
18+
count += 1
19+
20+
print(count)

0 commit comments

Comments
 (0)