#include<iostream>
#include<vector>
using namespace std;
int reverse(int x)
{
int arr[100000];
int temp = 0;
int remain = 0;
int sum = 0;
int i = 0;
temp = x;
while (temp > 0)
{
remain = temp % 10;
temp = temp / 10;
arr[i] = remain;
i++;
}
//cout << i << endl;
i = i - 1;
for (int j = 0; j <= i; j++)
{
for (int k = i-j; k > 0; k--)
{
arr[j] = arr[j] * 10;
}
//cout << arr[j] << endl;
sum = sum + arr[j];
}
return sum;
}
bool isPrime(int x)
{
int cnt = 0;
for (int i = 1; i <= x; i++)
{
if (x%i == 0)
{
cnt++;
}
}
if (cnt == 2)
{
return true;
}
else
{
return false;
}
}
int main()
{
int N = 0;
cin >> N;
vector<int> arr(N);
for (int i = 0; i < N; i++)
{
cin >> arr[i];
}
for (int i = 0; i < N; i++)
{
if (isPrime(reverse(arr[i])) == 1)
{
cout << reverse(arr[i]) << " ";
}
}
}
16번 (0) |
2020.08.28 |
15번 (0) |
2020.08.28 |
13번 (0) |
2020.08.26 |
12번 (0) |
2020.08.26 |
11번 (0) |
2020.08.26 |