- 考级202012-2:计算算式的值
比n小的最大质数
- 2023-7-27 13:58:23 @
#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
- 576
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 90
- Accepted
- 34
- Uploaded By