- 历届试题 带分数
比n小的最大质数
- 2023-7-27 14:01:10 @
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,a=0;
cin>>n;
for(int i=n-1;i>=2;i--)
{
a=0;
for(int j=2;j*j<=i;j++)
{
if(i%j==0)
{
a=1;
break;
}
}
if(a==0)
{
cout<<i;return 0;
}
}
return 0;
}
0 comments
No comments so far...
Information
- ID
- 631
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- # Submissions
- 2
- Accepted
- 1
- Uploaded By