| 比赛 | 
    NOIP2008集训模拟2 | 
    评测结果 | 
    C | 
    | 题目名称 | 
    美酒节赛羊 | 
    最终得分 | 
    0 | 
    | 用户昵称 | 
    王瑞祥K | 
    运行时间 | 
    0.000 s  | 
    | 代码语言 | 
    Pascal | 
    内存使用 | 
    0.00 MiB  | 
    | 提交时间 | 
    2008-11-11 11:15:00 | 
显示代码纯文本
program goat(input,output);
var
 f:array[1..3,1..2] of integer;
 s,p:longint;
 min:int64;
 i,j:integer;
procedure dg(time,long,pl:longint);
var i0:longint;
begin
 if long>=s then begin if time<min then min:=time; end;
 if long<s then  begin
  if pl>=p then dg(time+10,long+10,pl-10)
  else begin
   for i0:=1 to 3 do begin
    if (pl+f[i0,2]<=p)and(pl+f[i0,2]>=0) then
    dg(time+1,long+f[i0,1],pl+f[i0,2]);
   end;
  end;
 end;
end;
begin
 min:=maxint;
 f[1,1]:=1; f[1,2]:=-1;
 f[2,1]:=5; f[2,2]:=2;
 f[3,1]:=10; f[3,2]:=5;
 assign(f1,'goat.in');
 reset(f1);
 readln(f1,s,p);
 close(f1);
 dg(0,0,0);
 assign(f2,'goat.out');
 rewrite(f2);
 writeln(f2,min);
 close(f2);
end.