UDP广播协议叫吃饭


私信TA

用户名:Mustenaka

访问量:135684

签 名:

个人博客www.mustenaka.cn

等  级
排  名 12
经  验 23821
参赛次数 8
文章发表 197
年  龄 3
在职情况 学生
学  校 Sky_box
专  业 NE

  自我简介:

欢迎光临我的博客www.mustenaka.cn,Python,C#,U3D,C/C++开发合作可以找我

解题思路:
    又水了一发啊
参考代码:

#include<bits/stdc++.h>
#define hh ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long int li;
const int maxn=100005;
int n,k,ans;
int a[maxn]={0};
bool is_prime(){
	if(ans<2){
		return false;
	}
	for(int i=2;i<=sqrt(ans);i++){
		if(ans%i==0){
			return false;
		}
	}
	return true;
}
int main(){
	hh;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	ans=a[n-k+1]-a[k];
	if(is_prime()){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区