PersonalCorpus 版 (精华区)

276876 11:10:29 14 Nov 2002 Big Guava
1223 Pascal Accepted 0.14 sec 69K

program p1223_3;

var
    m,n,p,q:integer;
    c:array[1..1000,1..10] of word;
begin

{$IFNDEF ONLINE_JUDGE}
    assign(input,'input1223.txt');reset(input);
    assign(output,'output1223.txt');rewrite(output);
{$ENDIF}

    for m:=1 to 10 do c[1,m]:=1;
    for m:=1 to 1000 do begin
        c[m,1]:=m;
        for n:=2 to 10 do begin
            c[m,n]:=m;
            for p:=2 to m-1 do begin
                if c[p-1,n-1]>c[m-p,n] then q:=c[p-1,n-1] else q:
=c[m-p,n];
                if q+1<c[m,n] then c[m,n]:=q+1;
            end;
        end;
    end;

    while true do begin
        read(m); if m=0 then break;
        readln(n);
        if m>10 then m:=10;
        writeln(c[n,m]);
    end;
end.
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.051毫秒