a=[None]*301
def tree(n):
if n<2:
return 1
elif a[n] is not None:
return a[n]
else:
sum=0
for i in range(0,n):
sum+=tree(i)*tree(n-i-1)
a[n]=sum
return sum
def fac(n):
if(n<2):
return 1
return n*fac(n-1)
def Main():
while True:
n=int(input())
if n==0:
return 0
print(tree(n)*fac(n))
if __name__=='__main__':
Main()
def tree(n):
if n<2:
return 1
elif a[n] is not None:
return a[n]
else:
sum=0
for i in range(0,n):
sum+=tree(i)*tree(n-i-1)
a[n]=sum
return sum
def fac(n):
if(n<2):
return 1
return n*fac(n-1)
def Main():
while True:
n=int(input())
if n==0:
return 0
print(tree(n)*fac(n))
if __name__=='__main__':
Main()
Comments
Post a Comment