记录编号 |
13779 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Perform巡回演出 |
最终得分 |
100 |
用户昵称 |
maxiem |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.009 s |
提交时间 |
2009-10-10 10:31:38 |
内存使用 |
0.13 MiB |
显示代码纯文本
program candy;
var
price:array [1..10,1..10,0..30] of integer;
a:array [1..1000,1..10] of integer;
l,k,n,i,j,d:integer;
procedure fly;
var day,i,j,l:integer;
begin
for i:=1 to n do if price[1,i,1]<>0 then a[1,i]:=price[1,i,1];
for i:=2 to k do for j:=1 to n do for l:=1 to n do if (j<>l) then begin
day:=i mod price[l,j,0];
if day=0 then day:=price[l,j,0];
if (price[l,j,day]<>0) and (a[i-1,l]+price[l,j,day]<a[i,j])
then a[i,j]:=a[i-1,l]+price[l,j,day];
end;
end;
begin
assign (input,'candy.in');
reset (input);
assign (output,'candy.out');
rewrite (output);
repeat
readln (n,k);
if (n=0) and (k=0) then break;
fillchar (price,sizeof(price),0);
for i:=1 to k do for j:=1 to n do a[i,j]:=30000;
for i:=1 to n do begin
for j:=1 to i-1 do begin
read (price[i,j,0]);
for l:=1 to price[i,j,0] do read (price[i,j,l]);
end;
for j:=i+1 to n do begin
read (price[i,j,0]);
for l:=1 to price[i,j,0] do read (price[i,j,l]);
end;
end;
fly;
if a[k,n]<>30000 then writeln(a[k,n]) else writeln (0);
until (n=0) and (k=0);
close (input);
close (output);
end.