Submission
Status:
PPPPPPPPPPPPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: MyYammGods
Problemset: จำนวนเฉพาะก่อนหน้า
Language: cpp
Time: 0.005 second
Submitted On: 2025-10-15 13:19:00
#include <bits/stdc++.h>
using namespace std;
int main () {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
int Primes[6];
int count = 0;
while (true){
if(count == 5) break;
int prime = 1;
n = n - 1;
for (int i = 2 ; i*i <= n; i++){
if(n%i == 0){
prime = 0;
break;
}
}
if(prime == 1){
Primes[count] = n;
count++;
}
}
for (int i=4;i>=0;i--){
cout << Primes[i] << " ";
}
}