/ Vijos / 讨论 / 问答 /

大牛帮我看看哪里有问题

看了很久觉得没什么问题。。。。为啥1个点都过不了。。。。。抓狂

type

arr=array[0..30] of longint;

my=array[0..30] of boolean;

var

a,ans:arr;

h:my;

p:array[0..30] of int64;

i,n,m:longint;

find:boolean;

procedure makep;

var

i,j:longint;

begin

for i:=0 to n-1 do begin

p:=1;

for j:=n-1 downto n-i do p:=p*j;

for j:=1 to i do p:=p div j;

end;

end;

function count:longint;

var

i:longint;

begin

count:=0;

for i:=1 to n do inc(count,a[i]*p[i]);

end;

function countmax(var a:arr; d:longint):longint;

var

tmp,i,j,k:longint;

ok:my;

begin

countmax:=0;

fillchar(ok,sizeof(ok),0);

for i:=1 to d do begin

inc(countmax,a[i]*p[i]);

ok[i]:=true;

end;

for i:=n downto 1 do

if not h[i] then begin

tmp:=0;

for j:=d+1 to n do

if (not ok[j]) and (p[j]>tmp) then begin

tmp:=p[j];

k:=j;

end;

ok[k]:=true;

inc(countmax,i*p[k]);

end;

end;

function countmin(var a:arr; d:longint):longint;

var

tmp,i,j,k:longint;

ok:my;

begin

countmin:=0;

fillchar(ok,sizeof(ok),0);

for i:=1 to d do begin

inc(countmin,a[i]*p[i]);

ok[i]:=true;

end;

for i:=1 to n do

if not h[i] then begin

tmp:=0;

for j:=d+1 to n do

if (not ok[j]) and (p[j]>tmp) then begin

tmp:=p[j];

k:=j;

end;

ok[k]:=true;

inc(countmin,i*p[k]);

end;

end;

procedure dfs(d:longint);

var

i:longint;

check:boolean;

begin

if d=n+1 then begin

if count=m then begin

ans:=a;

find:=true;

end;

exit;

end;

for i:=1 to n do

if not h[i] then begin

h[i]:=true;

a[d]:=i;

check:=true;

if (d>n div 2) and (a[d]

2 条评论

  • @ 2009-10-29 19:31:17

    额。。我脑残忘说了。。1085

    p1085。。。。

  • @ 2009-10-29 19:12:17

    我也抓狂了...#

    同学您这是哪一题呢- 。-

  • 1