比赛 |
暑假培训二 |
评测结果 |
AAAAAAEEAT |
题目名称 |
分组 |
最终得分 |
70 |
用户昵称 |
Hamster |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-18 11:17:59 |
显示代码纯文本
program dataa;
var
a:array[1..20,1..3000] of byte;
m,n,s,i,j,z,q:longint;
fin,fout:text;
procedure init;
begin
for i:=1 to n do a[q,i]:=0;
end;
procedure copy;
begin
for i:=1 to m do a[q,i]:=a[q-1,i];
end;
procedure search(t,p,s:integer);
var
k:integer;
begin
k:=s-1;
repeat
begin
inc(k);
if k<=n-p then
begin
inc(t);
p:=p+k;
a[q,t]:=k;
for z:=1 to 1 do
begin
if t=m then
if p=n then
begin
inc(q);
copy;
end
else break
else search(t,p,k);
end;
a[q,t]:=0;
t:=t-1;
p:=p-k;
end;
end;
until k=n;
end;
begin
assign(fin,'dataa.in');
reset(fin);
assign(fout,'dataa.out');
rewrite(fout);
q:=1;
read(fin,n,m);
if m=1 then
begin
writeln(fout,'1');
writeln(fout,n);
end
else
begin
for j:=1 to n do
begin
init;
a[q,1]:=j;
search(1,j,j);
end;
writeln(fout,q-1);
end;
if m<>1 then
for i:=1 to q-1 do
begin
for j:=1 to m do write(fout,a[i,j],' ');
writeln(fout);
end;
close(fin);
close(fout);
end.