MCIRGAME - Point Connection Game in a Circle
Tác giả: flashmt
Ngôn ngữ: Pascal
const fi='';
fo='';
base=1000000;
digit=6;
maxn=160;
type bignum=array[0..30] of longint;
var n:longint;
a:array[0..maxn] of bignum;
procedure multi(i:longint);
var j,mem,t,x:longint;
begin
mem:=0; x:=4*i-2;
a[i,0]:=a[i-1,0];
for j:=1 to a[i,0] do
begin
t:=a[i-1,j]*x+mem;
a[i,j]:=t mod base;
mem:=t div base;
end;
if mem>0 then
begin
inc(a[i,0]);
a[i,a[i,0]]:=mem;
end;
end;
procedure divide(i:longint);
var j,mem,x,k:longint;
t:bignum;
begin
mem:=0; k:=i+1;
fillchar(t,sizeof(t),0);
for j:=a[i,0] downto 1 do
begin
x:=a[i,j]+mem*base;
if x<k then mem:=x
else
begin
t[j]:=x div k;
mem:=x mod k;
end;
end;
for j:=a[i,0] downto 1 do
if t[j]>0 then break;
a[i,0]:=j;
for j:=1 to a[i,0] do
a[i,j]:=t[j];
end;
procedure init;
var i:longint;
begin
a[0,0]:=1; a[0,1]:=1;
for i:=1 to maxn do
begin
multi(i);
divide(i);
end;
end;
procedure wf(re:bignum);
var i,j,t:longint; s:string;
begin
for i:=re[0] downto 1 do
begin
if i<re[0] then
begin
str(re[i],s);
t:=length(s);
for j:=t+1 to digit do write(0);
end;
write(re[i]);
end;
writeln;
end;
begin
assign(input,fi);
reset(input);
assign(output,fo);
rewrite(output);
init;
readln(n);
while n<>-1 do
begin
wf(a[n]);
readln(n);
end;
close(output);
close(input);
end.