Recurrence sequence

Compute the n-th term of a self-convolution recurrence where t(n) sums t(i)*t(n-1-i) for i from 0 to n-1, with n up to 35.

Easy3Dynamic programmingMathCombinatoricsImplementationInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

Consider the sequence t(n)t(n) defined by the following recurrence.

  • t(0)=1t(0) = 1
  • t(n)=t(0)t(n1)+t(1)t(n2)++t(n1)t(0)t(n) = t(0)t(n-1) + t(1)t(n-2) + \cdots + t(n-1)t(0) for n1n \ge 1

Applying the definition directly gives t(1)=t(0)t(0)=1t(1) = t(0)t(0) = 1, t(2)=t(0)t(1)+t(1)t(0)=2t(2) = t(0)t(1) + t(1)t(0) = 2, and t(3)=t(0)t(2)+t(1)t(1)+t(2)t(0)=5t(3) = t(0)t(2) + t(1)t(1) + t(2)t(0) = 5.

Given an integer nn, write a program that prints t(n)t(n).

Input

The first line contains an integer nn (0n350 \le n \le 35).

Output

Print t(n)t(n) on the first line. Every value up to t(35)t(35) fits in a signed 64-bit integer.