Skip to content

Commit 46fd93c

Browse files
committed
[Bronze I] Title: 팰린드롬수, Time: 92 ms, Memory: 9424 KB -BaekjoonHub
1 parent efae284 commit 46fd93c

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# [Bronze I] 팰린드롬수 - 1259
2+
3+
[문제 링크](https://www.acmicpc.net/problem/1259)
4+
5+
### 성능 요약
6+
7+
메모리: 9424 KB, 시간: 92 ms
8+
9+
### 분류
10+
11+
구현, 문자열
12+
13+
### 제출 일자
14+
15+
2026년 2월 6일 19:47:18
16+
17+
### 문제 설명
18+
19+
<p>어떤 단어를 뒤에서부터 읽어도 똑같다면 그 단어를 팰린드롬이라고 한다. 'radar', 'sees'는 팰린드롬이다.</p>
20+
21+
<p>수도 팰린드롬으로 취급할 수 있다. 수의 숫자들을 뒤에서부터 읽어도 같다면 그 수는 팰린드롬수다. 121, 12421 등은 팰린드롬수다. 123, 1231은 뒤에서부터 읽으면 다르므로 팰린드롬수가 아니다. 또한 10도 팰린드롬수가 아닌데, 앞에 무의미한 0이 올 수 있다면 010이 되어 팰린드롬수로 취급할 수도 있지만, 특별히 이번 문제에서는 무의미한 0이 앞에 올 수 없다고 하자.</p>
22+
23+
### 입력
24+
25+
<p>입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 1 이상 99999 이하의 정수가 주어진다. 입력의 마지막 줄에는 0이 주어지며, 이 줄은 문제에 포함되지 않는다.</p>
26+
27+
### 출력
28+
29+
<p>각 줄마다 주어진 수가 팰린드롬수면 'yes', 아니면 'no'를 출력한다.</p>
30+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// /dev/stdin
2+
const fs = require("fs");
3+
let input = fs
4+
.readFileSync("/dev/stdin")
5+
.toString()
6+
.split("\n")
7+
.map((x) => x.replace("\r", ""));
8+
9+
for (let i = 0; i < input.length; i++) {
10+
if (input[i] === "0") {
11+
break;
12+
}
13+
14+
let result = "yes";
15+
for (let j = 0; j < input[i].length; j++) {
16+
//console.log("input[i]", input[i], "input[i].at(-j)", input[i].at(-j), "j", j);
17+
//console.log(input[i][j], input[i].at(-(j + 1)));
18+
if (input[i][j] !== input[i][input[i].length - 1 - j]) {
19+
result = "no";
20+
break;
21+
}
22+
}
23+
console.log(result);
24+
}

0 commit comments

Comments
 (0)