- 萌萌的哈密顿
- 2009-10-18 19:48:42 @
我的方法是设f[i]为长度为i的种数,预处理时考虑一进一出的路径
用g表示s出发,t结束,中间长度为l的路径是否算过了,避免重复
if j=maxn do
begin
c:=c[i] div maxn+c;
c[i]:=c[i] mod maxn;
end;
while (c[0]>1)and(c[c[0]]=0) do dec(c[0]);
exit(c);
end;
procedure print(a:xtype);
var
i,j:longint;
begin
if a[0]=0 then begin write('0'); halt; end;
write(a[a[0]]);
for i:=a[0]-1 downto 1 do
begin
if a[i]>=10000000 then else
if a[i]>=1000000 then write('0') else
if a[i]>=100000 then write('00') else
if a[i]>=10000 then write('000') else
if a[i]>=1000 then write('0000') else
if a[i]>=100 then write('00000') else
if a[i]>=10 then write('000000') else
write('0000000');
write(a[i]);
end;
end;
begin
read(n,l);
f[0][0]:=1; f[0][1]:=1;
for i:=1 to n do read(next[i]);
for i:=1 to n do read(e[i]);
for i:=1 to n do
begin
s:=i; t:=i; tot:=e[i];
if tot+e[t]n then t:=1;
until tot+e[t]>l;
end;
for i:=1 to l do
for j:=1 to i-1 do
if j