解题思路:
又水了一发啊
参考代码:
#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 人评分
小九九 (C语言代码)浏览:528 |
【明明的随机数】 (C++代码)(C++库中有qsort函数直接快排,不用码排序代码hhh)浏览:974 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:564 |
C语言训练-自守数问题 (C语言代码) long long浏览:1062 |
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:439 |
Pascal三角 (C语言代码)浏览:1184 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:1195 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:916 |
1025题解浏览:734 |
简单的a+b (C语言代码)浏览:544 |