【新人求救】第K 极值
pascal吧
全部回复
仅看楼主
level 8
nnnkkk☞ 楼主
没错这是我的处女贴!!大神看过来.....看过来........
2015年10月17日 15点10分 1
level 8
nnnkkk☞ 楼主
program p1002;
var
n,k,i,p,t,j,m:integer;
a:array[0..10000]of integer;
f:boolean;
begin
readln(n,k);
for i:=1 to n do
read(a[i]);
for i:= 1 to n-1 do
begin
p:=1;
for j:=i+1 to n do
if a[p]>a[j] then p:=j;
t:=a[i]; a[i]:=a[p]; a[p]:=t;
end;
m:=a[k]-a[n-k+1];
f:=true;
if m<=2 then writeln('YES')
else for i:=2 to m div 2 do
if m mod i=0 then f:=false;
if (f)and(m>2) then writeln('YES');
if f=false then writeln('NO');
write(m);
end.
2015年10月17日 15点10分 2
writeln'NO'已经改过来了
2015年10月18日 01点10分
但还是错了
2015年10月18日 01点10分
level 8
nnnkkk☞ 楼主
全是wrang answer[不高兴]
2015年10月17日 15点10分 3
Wrong 拼错了累…这道题做过好多遍…但是现在…要睡觉觉[GRINNING FACE WITH SMILING EYES]
2015年10月17日 16点10分
[啊]
2015年10月18日 00点10分
level 8
nnnkkk☞ 楼主
大神大神快快来,求不沉
2015年10月17日 15点10分 5
level 9
if m<=2 then writeln('YES')?? 是NO 吧
2015年10月17日 16点10分 6
level 12
if m<2 then writeln(‘NO’);
2015年10月18日 00点10分 7
还是错了[泪]
2015年10月18日 00点10分
@nnnkkk☞ 找到了,在排序中的if没加begin end
2015年10月18日 01点10分
level 8
nnnkkk☞ 楼主
[泪]
2015年10月18日 00点10分 8
level 8
nnnkkk☞ 楼主
[泪]
2015年10月18日 00点10分 9
level 8
nnnkkk☞ 楼主
m的值也错了,然而金币已用光,看不到测试数据,
lz
无能啊啊[泪]
2015年10月18日 01点10分 10
level 8
nnnkkk☞ 楼主
写作业去了[泪]
2015年10月18日 03点10分 17
level 8
一个快排.........前后找一下第k大(小)的数........
2015年10月18日 04点10分 18
1