본 내용은 파이썬 알고리즘 문제풀이 (코딩테스트 대비) 강의를 토대로 작성하였습니다.
# 뒤집은 소수
import sys
sys.stdin=open("input.txt", "r")
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):
if x%i==0:
return False
return True
for x in a:
tmp=reverse(x)
if isPrime(tmp):
print(tmp, end=' ')
'Algorithm > 파이썬 알고리즘 문제풀이' 카테고리의 다른 글
[python/inflearn/section2] 점수계산 (0) | 2022.09.18 |
---|---|
[python/inflearn/section2] 주사위게임 (0) | 2022.09.18 |
[python/inflearn/section2] 소수(에라토스테네스 체) (0) | 2022.09.18 |
[python/inflearn/section2] 자릿수의 합 (0) | 2022.09.18 |
[python/inflearn/section2] 정다면체 (0) | 2022.09.18 |