看到这题第一感觉,集训就这破题水?于是乐呵呵的调了十几分钟...
思路么,就是简单的搜索,简直无语...
var
n,s,i:longint;
b:array[1..9]of longint;
a:array[1..1000000]of longint;
procedure work(step:longint);
var p:longint;
begin
if step=n+1 then begin
for i:=1 to n do write(a[i]);
writeln;
exit;
end;
for p:=1 to n do if b[p]=0 then begin
a[step]:=p;
b[p]:=1;
work(step+1);
b[p]:=0;
end;
end;
begin
//assign(input,‘arrange.in‘);reset(input);
//assign(output,‘arrange.out‘);rewrite(output);
readln(n);
s:=1;
for i:=2 to n do s:=s*i;
writeln(s);
work(1);
//close(input);
//close(output);
end.
哈,好晚了,睡咯。清明三天在家刷刷刷!
时间: 2024-10-27 14:20:26