program p1001; var i,tot,j,s,m,n,k:longint; a:array[1..10000]of longint; function prime(x:longint):boolean; var t,temp:longint; begin if (x=1) or (x=2)then exit(true); temp:=trunc(sqrt(abs(x)))+1; prime:=true; for t := 2 to temp do if (x mod t = 0) then exit(false); end; begin read (n,k); for i := 1 to n do read (a[i]); for i := 1 to n do for j := 1 to n do if a[i]>a[j] then begin tot:=a[i];a[i]:=a[j];a[j]:=tot; end; s:=a[k]-a[n+1-k]; if (not(prime(s)) or (s<2))then writeln('NO')else writeln('YES'); writeln(s); end.
http://www.tyvj.cn:8080/Problem_Show.asp?id=1001
还算顺利,发现最弱智的排序都能不超时,暂时就不写快排了吧~
P1002
谁拿了最多奖学金,读入搞不定。。郁闷,明天重试~