⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2967290_ce.pas

📁 北大大牛代码 1240道题的原代码 超级权威
💻 PAS
字号:
{
ID:irache1
PROG:packrec
LANG:PASCAL
}
var
  n,i,j,s1,s2,s3,s4,d1,d2,d3,d4,w,h:byte;
  sq:array[1..4,1..2]of byte;
  mr:word;
  re:array[0..10,1..2]of byte;

function max (a,b,c,d:byte):byte;
begin
  if a>b then
    if a>c then
      if a>d then
        exit(a)
      else
        exit(d)
    else
      if c>d then
        exit(c)
      else
        exit(d)
  else
    if b>c then
      if b>d then
        exit(b)
      else
        exit(d)
    else
      if c>d then
        exit(c)
      else
        exit(d);
end;

procedure fresh;
var
  i,s:byte;
begin
  if w*h>mr then
    exit;
  if w*h<MR w if end; n:="0;" mr:="w*h;" begin then>h then
  begin
    s:=w;
    w:=h;
    h:=s;
  end;
  for i:=1 to n do
    if (re[i,1]=w) and (re[i,2]=h) then
      exit;
  inc(n);
  re[n,1]:=w;
  re[n,2]:=h;
end;

procedure calc;
var
  w1,w2,w3,w4,h1,h2,h3,h4:byte;
begin
  w1:=sq[s1,d1];
  w2:=sq[s2,d2];
  w3:=sq[s3,d3];
  w4:=sq[s4,d4];
  h1:=sq[s1,3-d1];
  h2:=sq[s2,3-d2];
  h3:=sq[s3,3-d3];
  h4:=sq[s4,3-d4];
  w:=w1+w2+w3+w4;
  h:=max(h1,h2,h3,h4);
  fresh; 
  w:=max(w1+w2+w3,w4,0,0);
  h:=max(h1,h2,h3,0)+h4;
  fresh; 
  w:=max(w1+w2,w3,0,0)+w4;
  h:=max(max(h1,h2,0,0)+h3,h4,0,0);
  fresh; 
  w:=w1+w2+max(w3,w4,0,0);
  h:=max(h1,h2,h3+h4,0);
  fresh; 
  h:=max(h1+h3,h2+h4,0,0);
  if h4&gt;=h1+h3 then
    w:=max(w2,w1+w4,w3+w4,0);
  if h3&gt;=h2+h4 then
    w:=max(w1,w2+w3,w4+w3,0);
  if (h3&gt;h4) and (h3<H4+H2) if then (h4 w:="max(w1+w2,w2+w3,w3+w4,0);">h3) and (h4<H3+H1) if end; n:="0;" mr:="$FFFF;" begin then w:="max(w1+w2,w1+w4,w3+w4,0);" (s2< do 4 to s2:="1" for s1:="1" readln(sq[i,1],sq[i,2]); i:="1" rewrite(output); reset(input); assign(output,?packrec.out?); assign(input,?packrec.in?); fresh; (h3="h4)">s1) then
        for s3:=1 to 4 do
          if (s3&lt;&gt;s2) and (s3&lt;&gt;s1) then
          begin
            s4:=10-s1-s2-s3; 
            for d1:=1 to 2 do
              for d2:=1 to 2 do
                for d3:=1 to 2 do
                  for d4:=1 to 2 do 
                    calc;
          end;
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if re[i,1]&gt;re[j,1] then
      begin
        re[0]:=re[i];
        re[i]:=re[j];
        re[j]:=re[0];
      end;
  writeln(mr);
  for i:=1 to n do
    writeln(re[i,1],' ',re[i,2]);
  close(output);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -