We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9bd39fb commit 4b3eae4Copy full SHA for 4b3eae4
minjeong/BruteForce/2024-08-15-[백준]-#30446-회문수.py
@@ -0,0 +1,23 @@
1
+import sys
2
+input = sys.stdin.readline
3
+
4
+n = int(input())
5
+answer = []
6
7
+limit = 10 ** (len(str(n)) // 2 + 1) # 반복 범위 설정 (n의 자릿수의 절반에서 1을 더한 값을 10의 지수)
8
9
+# 회문수를 생성하여 n과 비교
10
+for i in range(1, limit):
11
+ half = str(i)
12
13
+ # 짝수 자리수 회문수
14
+ p_even = int(half + half[::-1])
15
+ if p_even <= n:
16
+ answer.append(p_even)
17
18
+ # 홀수 자리수 회문수
19
+ p_odd = int(half + half[-2::-1])
20
+ if p_odd <= n:
21
+ answer.append(p_odd)
22
23
+print(len(answer))
0 commit comments