Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: Kei
Problemset: จำนวนเฉพาะก่อนหน้า
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-08 17:20:43
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
bool isprime(ll a){
if(a<2) return false;
if(a==2) return true;
ll d=2;
while(d*d <= a){
if(a%d==0) return false;
d++;
}
return true;
}
void solve(){
ll p,res;
vector<ll> v(5);
int i=0;
int cnt=5;
cin >> p;
res=p;
while(cnt>0){
while(res>=2){
res--;
if(isprime(res)) break;
}
v[cnt-1] = res;
cnt--;
}
for(ll& x : v){
cout << x << ' ';
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}