Notice
Recent Posts
Recent Comments
Link
Star_project
[인프런] 2. 자료구조와 알고리즘 입문 8. 뒤집은 소수 본문
import sys
from sklearn.utils import resample
sys.stdin=open("pythonalgorithm/섹션 2/8. 뒤집은 소수/in5.txt","rt")
n=int(input())
a=list(map(int, input().split()))
def reverse(x):
res=0
while x>0:
t=x%10
res=res*10+t
x=x//10
return res
def isPrime(x):
if x==1:
return False
for i in range(2, x//2+1):
if x%i==0:
return False
# false 당하면 if 문 끝남
else:
return True
# for 문 이 False 안당하고 정상적으로 종료되면 else 문 실행
for x in a:
tmp=reverse(x)
if isPrime(tmp):
print(tmp, end=' ')
'코딩테스트 > Python' 카테고리의 다른 글
[인프런] 2. 자료구조와 알고리즘 입문 10.점수 계산 (0) | 2022.07.12 |
---|---|
[인프런] 2. 자료구조와 알고리즘 입문 9.주사위 게임 (0) | 2022.07.12 |
[프로그래머스] 자릿수 더하기 (0) | 2022.07.11 |
2. 자료구조와 알고리즘 입문 7. 소수(에라토스테네스 체) (0) | 2022.07.11 |
2. 자료구조와 알고리즘 입문 6.자릿수의 합 (0) | 2022.07.11 |