1 /**************************************************************
2 Problem: 1002
3 User: 935671154
4 Language: C++
5 Result: Accepted
6 Time:44 ms
7 Memory:2068 kb
8 ****************************************************************/
9
10 //Author : Asm.Def
11 #include <iostream>
12 #include <cctype>
13 #include <cstdio>
14 #include <vector>
15 #include <algorithm>
16 #include <cmath>
17 #include <queue>
18 using namespace std;
19 inline void getd(int &x){
20 char c = getchar();
21 bool minus = 0;
22 while(!isdigit(c) && c != ‘-‘)c = getchar();
23 if(c == ‘-‘)minus = 1, c = getchar();
24 x = c - ‘0‘;
25 while(isdigit(c = getchar()))x = x * 10 + c - ‘0‘;
26 if(minus)x = -x;
27 }
28 /*======================================================*/
29 const int maxn = 102;
30
31 struct BigN{
32 #define base 10000
33 #define maxl 1000
34 int A[maxl], len;
35 BigN(){len = 1, A[0] = 0;}
36 BigN &operator = (const BigN &x){
37 len = 0;
38 while(len < x.len){A[len] = x.A[len]; ++len;}
39 return *this;
40 }
41 BigN &operator = (int k){len = 1;A[0] = k; return *this;}
42 BigN &operator += (const BigN &x){
43 int i, mor = 0;
44 for(i = 0;i < x.len || mor;++i){
45 if(i < len)mor += A[i];
46 if(i < x.len)mor += x.A[i];
47 A[i] = mor % base;
48 mor /= base;
49 }
50 if(i > len)len = i;
51 return *this;
52 }
53 }f[maxn], S[maxn];
54
55 inline void work(int k){
56 int i;
57 if(!k){printf("0\n");return;}
58 f[0] = 1, f[1] = 1, S[1] = 1;
59 if(k == 1){printf("1\n");return;}
60 for(i = 2;i <= k;++i){
61 f[i] = 1; f[i] += f[i-1]; f[i] += S[i-1];
62 S[i] = S[i-1]; S[i] += f[i];
63 }
64 S[k] += S[k-1];
65 i = S[k].len - 1;
66 printf("%d", S[k].A[i]);
67 while(i)
68 printf("%04d", S[k].A[--i]);
69 putchar(‘\n‘);
70 }
71
72 int main(){
73 #if defined DEBUG
74 freopen("test", "r", stdin);
75 #endif
76 int k;
77 getd(k);
78
79 work(k);
80
81 #if defined DEBUG
82 cout << endl << (double)clock()/CLOCKS_PER_SEC << endl;
83 #endif
84 return 0;
85 }