解题思路:
注意事项:
参考代码:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void is_prime(int n)
{
if (n<2)cout << "NO" << endl;
else if (n == 2)cout << "YES" << endl;
else
{
int ok = 1;
for (int i = 2; i*i<n; i++)
{
if (n%i == 0)
{
ok = 0;
break;
}
}
if (ok)cout << "YES" << endl;
else cout << "NO" << endl;
}
}
int main()
{
int n, k;
cin >> n >> k;
vector<int>a(n);
for (int i = 0; i<a.size(); i++)
cin >> a[i];
sort(a.begin(), a.end());
int m = a[n - k] - a[k - 1];
is_prime(m);
cout << m << endl;
return 0;
}
0.0分
0 人评分