Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: chickennuggget

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

Language: cpp

Time: 0.004 second

Submitted On: 2025-10-02 14:52:56

#include<bits/stdc++.h>
using namespace std;
int main ()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	int box[5];
	int count=0;
	int countp;
	cin>>n;
	for(int i=n-1;i>=2;i--)
	{
		countp=0;
		for(int j=2;j<=sqrt(i);j++)
		{
			if(i%j==0)
			{
				countp+=1;
			}
		}
//		cout<<i<<" "<<countp<<"\n";
		if(countp==0)
		{
			count+=1;
			box[count]=i;
		}
		if(count==5)
		{
			break;
		}
	}
	for(int i=5;i>0;i--)
	{
		cout<<box[i]<<" ";
	}
	return 0;
}