Fractions are better when continued

시간 제한1초메모리 제한1024 MB

요약
N이 최대 40일 때, 1에서 시작해 1/(1+...)을 N번 겹쳐 만든 유한 연분수 p_N의 분자를 구한다.
난이도

쉬움10점 중 3점

유형
동적 계획법, 수학, 재귀
정답자
아직 제출이 없습니다

문제

Little Charles was one of the best competitive programmers in the world. However, he never really liked programming. Now that he is retired, he can dedicate his studies to what he really loves: continued fractions.

To prepare for the upcoming Imensa Competição de Phrações Contínuas (ICPC), he needs to solve the following problem:

Define p_0=1p\_0 = 1 as the level 00 fraction. Then define: p_1=11+1p\_1 = \frac{1}{1+1} as the level 11 fraction, p_1p\_1. And also, p_2=11+11+1p\_2 = \frac{1}{1 + \frac{1}{1+1}} as the level 22 fraction, p_2p\_2, and so on.

Given an integer value NN, help Charles determine the value of the numerator of the fraction p_Np\_N.

입력

The first and only line contains an integer NN (1≤N≤401 ≤ N ≤ 40).

출력

The value p_Np\_N can be written as a fraction of the form ab\frac{a}{b}, where aa and bb are coprime. Print a line containing the value of a.

예제2

  1. 예제 1

    입력
    2
    
    예상 출력
    2
    
  2. 예제 2

    입력
    10
    
    예상 출력
    89