https://www.acmicpc.net/problem/1747
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <set>
#include <regex>
#include <tuple>
#include <cmath>
#include <cstddef>
using namespace std;
bool isPalindrame(int target)
{
string temp_str = to_string(target);
char const* temp = temp_str.c_str();
int s = 0;
int e = temp_str.size() - 1;
while (s < e)
{
if (temp[s] != temp[e])
{
return false;
}
s++;
e--;
}
return true;
}
int main(void)
{
//ios::sync_with_stdio(false);
//cin.tie(NULL);
//std::cout.tie(NULL);
vector<int> numbers = { 2, 3, 3, 5 };
long n;
cin >> n;
long A[10000001];
for (int i = 2; i < 10000001; i++)
{
A[i] = i;
}
for (int i = 2; i <= sqrt(10000001); i++)
{
if (A[i] == 0)
{
continue;
}
for (int j = i + i; j < 10000001; j = j + i)
A[j] = 0;
}
int i = n;
while (true)
{
if (A[i] != 0)
{
int result = A[i];
if (isPalindrame(result))
{
cout << result << endl;
break;
}
}
i++;
}
return 0;
}'콘솔창 & 윈도우창 > 코딩 테스트' 카테고리의 다른 글
| LV.2 미로탈출 (0) | 2025.10.26 |
|---|---|
| [백준 골드 1] 1016 제곱 ㄴㄴ 수 (0) | 2025.08.11 |
| 회문 순열 (2) | 2025.08.07 |
| 코딩 인터뷰 문제 6가지 (4) | 2025.08.03 |
| 프로그래머스 LV.2 올바른 괄호 (2) | 2025.07.27 |