Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5fd1629

Browse files
[Bronze I] Title: 팰린드롬수, Time: 76 ms, Memory: 30840 KB -BaekjoonHub
1 parent 305cdeb commit 5fd1629

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# [Bronze I] 팰린드롬수 - 1259
2+
3+
[문제 링크](https://www.acmicpc.net/problem/1259)
4+
5+
### 성능 요약
6+
7+
메모리: 30840 KB, 시간: 76 ms
8+
9+
### 분류
10+
11+
구현(implementation), 문자열(string)
12+
13+
### 문제 설명
14+
15+
<p>어떤 단어를 뒤에서부터 읽어도 똑같다면 그 단어를 팰린드롬이라고 한다. 'radar', 'sees'는 팰린드롬이다.</p>
16+
17+
<p>수도 팰린드롬으로 취급할 수 있다. 수의 숫자들을 뒤에서부터 읽어도 같다면 그 수는 팰린드롬수다. 121, 12421 등은 팰린드롬수다. 123, 1231은 뒤에서부터 읽으면 다르므로 팰린드롬수가 아니다. 또한 10도 팰린드롬수가 아닌데, 앞에 무의미한 0이 올 수 있다면 010이 되어 팰린드롬수로 취급할 수도 있지만, 특별히 이번 문제에서는 무의미한 0이 앞에 올 수 없다고 하자.</p>
18+
19+
### 입력
20+
21+
<p>입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 1 이상 99999 이하의 정수가 주어진다. 입력의 마지막 줄에는 0이 주어지며, 이 줄은 문제에 포함되지 않는다.</p>
22+
23+
### 출력
24+
25+
<p>각 줄마다 주어진 수가 팰린드롬수면 'yes', 아니면 'no'를 출력한다.</p>
26+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 팰린드롬수
2+
while 1:
3+
n = input()
4+
if n == "0": break
5+
size = len(n)
6+
mid = size // 2
7+
left = n[:mid]
8+
9+
if size % 2 == 0:
10+
right = "".join(reversed(n[mid:]))
11+
else:
12+
right = "".join(reversed(n[mid + 1:]))
13+
14+
if left == right:
15+
print("yes")
16+
else:
17+
print("no")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /