Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Score: 100
User: lazybw_
Problemset: จำนวนเฉพาะก่อนหน้า
Language: cpp
Time: 0.003 second
Submitted On: 2025-01-18 21:17:26
#include <bits/stdc++.h>
using namespace std;
int isPrime(long long n) {
if (n%2 == 0) return 0;
for (int i = 3; i <= sqrt(n); i+=2) {
if (n%i == 0) return 0;
} return 1;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false); cout.tie(nullptr);
long long x; cin>>x; int c = 0; int p[5];
if (x < 14) {
cout<<"2 3 5 7 11 "; return 0;
} if (x%2 == 0) ++x;
while (c < 5) {
x-=2;
if (isPrime(x) == 1) {p[4-c] = x; ++c;}
}
for (auto i : p) cout<<i<<' ';
return 0;
}