Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: KurtCobain
Problemset: จำนวนเฉพาะก่อนหน้า
Language: cpp
Time: 0.003 second
Submitted On: 2025-10-03 21:34:22
#include <iostream>
#include <cmath>
#include <set>
using namespace std;
int main(){
int n;
cin >> n;
int b = 0;
set<int> answer = {};
for (int i=n-1;i>0;i--){
if (b == 5) break;
bool is_found = false;
for (int j=2;j<=sqrt(i);j++){
if (i % j == 0){
is_found = true;
}
}
if (!is_found){
answer.insert(i);
b++;
}
}
for (auto &x : answer){
cout << x << " ";
}
}