比赛 暑假培训二 评测结果 AAAAAAAAAA
题目名称 分组 最终得分 100
用户昵称 辨机ZN 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-18 10:48:08
显示代码纯文本
program ex(f1,f2);
 type
  st=array [1..15] of integer;
  zn=array [1..5000,1..15] of integer;
 var
  a:st; c:zn; i,j,k,m,n,n2:integer; f1,f2:text;
  answer:longint; q:integer;
 procedure shuchu;
  var i:integer;  flag:boolean;
   begin
    flag:=true;
    for i:=1 to m-1 do
    if a[i]>a[i+1] then
     begin
      flag:=false;
      break;
     end;
    if flag then
    begin
    inc(q);
    inc(answer);
    for i:=1 to m do c[q,i]:=a[i];
    end;
   end;

 procedure try(step:integer);
  var i:integer;
 begin
    if step<m then
    begin
    for i:=1 to n do
     begin
      if n2>0 then
         begin
          a[step]:=i;
          n2:=n2-i;
          try(step+1);
          n2:=n2+i;
         end;
     end;
    end
    else
     begin
        if step=m
        then
         begin
          a[step]:=n2;
          shuchu;
         end;
     end;
 end;
 begin
  assign(f1,'dataa.in'); reset(f1);
  assign(f2,'dataa.out'); rewrite(f2);
  readln(f1,n,m);
  answer:=0;
  q:=0;
  n2:=n;
  for i:=1 to m do a[i]:=0;
  try(1);
  writeln(f2,answer);
  for i:=1 to q do
   begin
    for j:=1 to m-1 do write(f2,c[i,j],' ');
    writeln(f2,c[i,m]);
   end;
  close(f1);
  close(f2);
 end.