Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: 666whynot
Problemset: จำนวนเฉพาะก่อนหน้า
Language: cpp
Time: 0.002 second
Submitted On: 2025-07-29 10:34:01
#include <bits/stdc++.h>
using namespace std;
bool primenumber(int n){
for (int i=2;i*i<=n;i++) if (n % i == 0) return false;
return true;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
int n;cin >> n;
int cnt = 0;
vector<int> ans;
for(int i=n-1;i>1;i--){
if(primenumber(i)){
ans.push_back(i);
if(ans.size() == 5)break;
}
}
sort(ans.begin(),ans.end());
for(int x : ans) cout << x << ' ';
}