Submission
Status:
xxxxxxxxxxxxxxxxxxxx
Subtask/Task Score:
0/100
Score: 0
User: Bestzu
Problemset: จำนวนเฉพาะก่อนหน้า
Language: cpp
Time: 0.047 second
Submitted On: 2025-10-15 11:46:46
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long int
using namespace std;
const ll N = 8000000;
vector<ll> prime;
vector<bool> is_prime(N, true);
void sieve() {
is_prime[0] = is_prime[1] = false;
for(ll i = 2; i <= N; i++) {
if(is_prime[i]) {
prime.push_back(i);
for(ll j = i*i; j <= N; j += i) {
is_prime[j] = false;
}
}
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
sieve();
ll n; cin >> n;
vector<long long int>::iterator it = lower_bound(prime.begin(), prime.end(), n);
for(ll i = 5; i >= 1; i--) {
cout << *(it - i) << " ";
}
return 0;
}