讨论 / 太坑。。这题,交了10遍
huhang1996 2013-07-03 12:10:00
点我顶贴 收藏 删除
RT
#1 niyufan@2013-11-04 15:37:00
回复 删除
program peanuts;

var

M,N,K,i,j,x,y,int,sum:integer;

P1,P2:array[0..500]of integer;

b:boolean;

procedure peanut(a,b:integer;var d:boolean);

var time:integer;

begin

if x<>0 then time:=abs(a-x)+abs(b-y)+1+a

else time:=a+1+a;

if K>=time then

begin

K:=K-time+a;

sum:=sum+i;

x:=a;

y:=b;

end

else d:=true;

end;

begin

read(M,N,K);

for i:=1 to m do

for j:=1 to n do

begin

read(int);

if int<>0 then

begin

P1[int]:=i;

P2[int]:=j;

end;

end;

for i:=500 downto 1 do

if (P1[i]<>0) and (b=false)

then peanut(P1[i],P2[i],b);

write(sum);

end.

过了

#2 BarackObama@2013-11-04 17:36:50
回复 删除
题目的关键是思路,只看代码就没意思了
#3 潘鹤翔@2014-01-27 10:32:24
回复 删除
无限的同意
查看更多回复
提交回复