记录编号 7047 评测结果 AAAAAAAAAA
题目名称 分组 最终得分 100
用户昵称 GravatarMayLava 是否通过 通过
代码语言 Pascal 运行时间 0.022 s
提交时间 2008-11-06 10:11:15 内存使用 0.15 MiB
显示代码纯文本
program MayLava;
var
 a:array[1..1000,1..20]of integer;
 b,c:array[1..20]of integer;
 n,m,sum,i:longint;
procedure start;
 var
  f:text;
 begin
  assign(f,'dataa.in');
  reset(f);
  readln(f,n,m);
  close(f);
  sum:=0;
 end;
procedure hunt(x,y:longint);
 var
  i:longint;
 begin
  if y=0 then exit;
  if x=m then begin
   if y<b[x-1] then exit;
   inc(sum);
   for i:=1 to m-1 do
    a[sum][i]:=b[i];
   a[sum][m]:=y;
   exit;
  end;
  for i:=b[x-1] to y do begin
   b[x]:=i;
   hunt(x+1,y-i);
  end;
 end;
procedure print;
 var
  i,j:longint;
  f:text;
 begin
  assign(f,'dataa.out');
  rewrite(f);
  writeln(f,sum);
  for i:=1 to sum do begin
   for j:=1 to m-1 do
    write(f,a[i,j],' ');
   writeln(f,a[i,m]);
  end;
  close(f);
 end;
BEGIN
 start;
 for i:=1 to (n div m) do begin
  b[1]:=i;
  hunt(2,n-i);
 end;
 print;
END.