比赛 NOIP2008集训模拟2 评测结果 ATTTTEEEEE
题目名称 美酒节赛羊 最终得分 10
用户昵称 maxiem 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-11 10:39:13
显示代码纯文本
program goat;
var
  min,s:longint;
  p:byte;
procedure go(d,tir,time:longint);
var i:byte;
begin
  if d>=s then begin
    if min>time then min:=time;
  end
  else begin
    for i:=1 to 3 do begin
      case i of 
        1:if tir=0 then go(d+1,0,time+1) else go(d+1,tir-1,time+1);
        2:if tir+2<=p then go(d+5,tir+2,time+1);
        3:if tir+5<=p then go(d+10,tir+5,time+1);
      end;
    end;
  end;
 end;
begin
  assign (input,'goat.in');
  reset (input);
  readln (s,p);
  close (input);
  assign (output,'goat.out');
  rewrite (output);
  min:=maxlongint;
  go(0,0,0);
  writeln (min);
  close (output);
end.