比赛 NOIP2008集训模拟2 评测结果 ATATTTEEEE
题目名称 美酒节赛羊 最终得分 20
用户昵称 rottenwood 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-11 11:12:08
显示代码纯文本
program goat;
const
v:array[1..3] of integer=(-1,2,5);
w:array[1..3] of integer=(1,5,10);
type
shuzu=array[1..250] of integer;
shuzu1=array[1..3] of longint;
var
f,b:shuzu;
m:shuzu1;
p,i,j,k,n,temp,s,min:longint;
procedure print(x:longint);
  begin
  if x<min then min:=x;
  end;
procedure search(now,t,time:longint);
 var
 i,j,k:longint;
  begin
  if time>min then exit;
  if now>=s then print(time)
     else begin
     if t>p then t:=p;
     for i:=3 downto 1 do
     begin
        if t>v[i] then search(now+w[i],t-v[i],time+1);
         if t=0 then search(now+10,t+10,time+10);
         end;
         end;
         end;
begin
assign(input,'goat.in');reset(input);
assign(output,'goat.out');rewrite(output);
readln(s,p);
min:=maxlongint;
search(0,p,0);
writeln(min);
end.