3
30
2015
0

Tyvj 1001 第K极值

#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int a[10000],m,n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;++i)
		scanf("%d",&a[i]);
	sort(a,a+n);
	m=a[n-k]-a[k-1];
	if (m<2) {
        printf("NO\n%d",m);
        return 0;
	}
	for (int i=2;i<=sqrt(m);++i)
		if (m%i==0) {
			printf("NO\n%d",m);
			return 0;
		}
	printf("YES\n%d",m);
	return 0;
}
Category: 题解 | Tags: Tyvj 模拟 | Read Count: 168

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com