From 21cd5a206f4a841c80113a50ec01d0e99d27b3c9 Mon Sep 17 00:00:00 2001 From: SSUM <116950962+ssum21@users.noreply.github.com> Date: Sun, 16 Feb 2025 16:02:09 +0900 Subject: [PATCH] =?UTF-8?q?[Silver=20I]=20Title:=20=EC=86=8C=EC=88=98&?= =?UTF-8?q?=ED=8C=B0=EB=A6=B0=EB=93=9C=EB=A1=AC,=20Time:=203540=20ms,=20Me?= =?UTF-8?q?mory:=2034536=20KB=20-BaekjoonHub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 백준/Silver/1747. 소수&팰린드롬/README.md | 30 +++++++++++++++++++ .../1747. 소수&팰린드롬/소수&팰린드롬.py | 29 ++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 백준/Silver/1747. 소수&팰린드롬/README.md create mode 100644 백준/Silver/1747. 소수&팰린드롬/소수&팰린드롬.py diff --git a/백준/Silver/1747. 소수&팰린드롬/README.md b/백준/Silver/1747. 소수&팰린드롬/README.md new file mode 100644 index 0000000..881fe96 --- /dev/null +++ b/백준/Silver/1747. 소수&팰린드롬/README.md @@ -0,0 +1,30 @@ +# [Silver I] 소수&팰린드롬 - 1747 + +[문제 링크](https://www.acmicpc.net/problem/1747) + +### 성능 요약 + +메모리: 34536 KB, 시간: 3540 ms + +### 분류 + +브루트포스 알고리즘, 수학, 정수론, 소수 판정, 에라토스테네스의 체 + +### 제출 일자 + +2025년 2월 16일 16:00:51 + +### 문제 설명 + +

어떤 수와 그 수의 숫자 순서를 뒤집은 수가 일치하는 수를 팰린드롬이라 부른다. 예를 들어 79,197과 324,423 등이 팰린드롬 수이다.

+ +

어떤 수 N (1 ≤ N ≤ 1,000,000)이 주어졌을 때, N보다 크거나 같고, 소수이면서 팰린드롬인 수 중에서, 가장 작은 수를 구하는 프로그램을 작성하시오.

+ +### 입력 + +

첫째 줄에 N이 주어진다.

+ +### 출력 + +

첫째 줄에 조건을 만족하는 수를 출력한다.

+ diff --git a/백준/Silver/1747. 소수&팰린드롬/소수&팰린드롬.py b/백준/Silver/1747. 소수&팰린드롬/소수&팰린드롬.py new file mode 100644 index 0000000..0823155 --- /dev/null +++ b/백준/Silver/1747. 소수&팰린드롬/소수&팰린드롬.py @@ -0,0 +1,29 @@ +import sys +import math + +input = sys.stdin.readline + +def pellindrom(num): + num = str(num) + num_len = len(num) // 2 + for i in range(num_len): + if(num[i]!=num[-(i+1)]): + return False + return True + +def isPrime(num): + if (num==1): + return False + for i in range(2, (int(math.sqrt(num))+1)): + if num%i == 0: + return False + return True + +N = int(input()) + +while True: + if (isPrime(N) and pellindrom(N)): + print(N) + break + else: + N+=1