Submission

Status:

P--P------P---PP-PPP

Subtask/Task Score:

40/100

Score: 40

User: Kei

Problemset: จำนวนเฉพาะก่อนหน้า

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-08 17:19:11

#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-=2;
            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;
}