比赛 暑假培训三 评测结果 AAATTT
题目名称 数列问题 最终得分 50
用户昵称 ReimBurSe. 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-19 10:05:10
显示代码纯文本
Program dfs3;

Var
panduan:array [1..50] of boolean;
h,a:array [1..50] of integer;
n,j,o:integer;
f1,f2:text;

procedure try(i:integer);
var m,p,q,k,j,l,b:integer;
begin
 for k:=1 to n do begin
  if panduan[k] then begin
   a[i]:=k;
   panduan[k]:=false;
   if i=n then begin
    p:=0; q:=1;
    for m:=1 to (n-1) do begin
     p:=p+1; q:=q+1;
     h[m]:=a[p]+a[q];
    end;
    l:=1;
    for m:=1 to (n-1) do begin
     b:=2;
     repeat
      if h[m] mod b=0 then l:=0
      else b:=b+1;
     until (l=0) or (b>=h[m]/2);
    end;
    if l=1 then begin
     for m:=1 to n do write(f2,a[m],' ');
     writeln(f2);
     o:=o+1;
    end;
   end
   else try(i+1);
   panduan[k]:=true;
  end;
 end;
end;

Begin
assign(f1,'dfs3.in');
assign(f2,'dfs3.out');
reset(f1);
rewrite(f2);
read(f1,n);
o:=0;
for j:=1 to n do
 panduan[j]:=true;
try(1);
write(f2,o);
close(f1);
close(f2);
End.