Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: Catpao

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

Language: cpp

Time: 0.004 second

Submitted On: 2025-09-29 08:44:11

#include<bits/stdc++.h>
using namespace std;
int b[10];
int main()
{
	int n,d,cnt = 0;
	cin>>n;
	bool a = false;
	set<int> c;
	for(int i=n-1;i>=2;i--){
		d = i;
		for(int j=2;j<=sqrt(d);j++){
			if(d%j == 0){
				a = true;
			}
		}
		if(a == false){
			c.insert(d);
			cnt++;
			if(cnt == 5){
				break;
			}
		}
		a = false;
	}
	for(auto  e:c){
		cout<< e << ' ';
	}
}