MCIRGAME - Point Connection Game in a Circle
Tác giả: ll931110
Ngôn ngữ: Pascal
Program MCIRGAME;
Const
maxn = 150;
maxv = 10000000;
Var
F: array[0..maxn,1..150] of qword;
k: array[1..100] of qword;
n: integer;
Procedure optimize;
Var
i,j,s,p,q,tmp: integer;
Begin
Fillchar(F, sizeof(F), 0);
F[0,1]:= 1;
F[1,1]:= 1;
For i:= 2 to maxn do
For j:= 0 to i - 1 do
Begin
Fillchar(k, sizeof(k), 0);
For p:= 1 to 50 do
For q:= 1 to 50 do
Begin
tmp:= p + q - 1;
k[tmp]:= k[tmp] + F[j,p] * F[i - 1 - j,q];
If k[tmp] > maxv then
Begin
k[tmp + 1]:= k[tmp + 1] + k[tmp] div maxv;
k[tmp]:= k[tmp] mod maxv;
End;
End;
For s:= 1 to 100 do
Begin
F[i,s]:= F[i,s] + k[s];
If F[i,s] >= maxv then
Begin
F[i,s + 1]:= F[i,s + 1] + F[i,s] div maxv;
F[i,s]:= F[i,s] mod maxv;
End;
End;
End;
End;
Procedure solve;
Var
st: string;
i,j,t: integer;
Begin
Repeat
Readln(n);
If n <> -1 then
Begin
t:= 100;
While F[n,t] = 0 do dec(t);
Write(F[n,t]);
For i:= t - 1 downto 1 do
Begin
str(F[n,i], st);
For j:= 1 to 7 - length(st) do write(0);
Write(st);
End;
Writeln;
End;
Until n = -1;
End;
Begin
optimize;
solve;
End.