Submission
Status:
-----------Px---xx--
Subtask/Task Score:
5/100
Score: 5
User: Neozaawwman1
Problemset: จำนวนเฉพาะก่อนหน้า
Language: cpp
Time: 0.011 second
Submitted On: 2025-10-10 11:10:06
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<int> check(n, 0);
vector<int> prime;
vector<int> rprime;
check[0]=check[1]=1;
for(int i=0; i*i<n; i++){
if(check[i]==0){
for(int j=i*i; j<n; j+=i){
check[j]=1;
}
}
}
for(int i=0; i<=n; i++){
if(check[i]==0){
prime.push_back(i);
}
}
for(int i=0; i<5; i++){
rprime.push_back(prime[prime.size()-5+i]);
}
for(auto ele:rprime){
cout<<ele<<" ";
}
return 0;
}