Under construction

Still being built. Things may change

Recurrence sequence

Interview

Time limit5sMemory limit512 MB

Summary
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.
Level

Easy3 of 10

Topics
Dynamic programming, Math, Combinatorics, Implementation
Solved
No attempts yet

Problem

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

  • t(0)=1t(0) = 1
  • t(n)=t(0)t(n−1)+t(1)t(n−2)+⋯+t(n−1)t(0)t(n) = t(0)t(n-1) + t(1)t(n-2) + \cdots + t(n-1)t(0) for n≥1n \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 (0≤n≤350 \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.

Examples2

  1. Example 1

    Input
    3
    
    Expected output
    5
    
  2. Example 2

    Input
    25
    
    Expected output
    4861946401452