Posted on 2009-09-15 16:01
Hero 阅读(124)
评论(0) 编辑 收藏 引用 所属分类:
Algorithm
1 //SGU 123 .CPP_VS Accepted 23 ms 0 kb
2 #include <iostream>
3 using namespace std ;
4
5 const int size = 42 ;
6
7 unsigned fib[50] ;
8 int inn ;
9
10 void InitFIB()
11 {
12 fib[1] = fib[2] = 1 ;
13
14 for( int i=3; i<=size; i++ )
15 {
16 fib[i] = fib[i-1] + fib[i-2] ;
17 }
18
19 for( int i=2; i<=size; i++ )
20 {
21 fib[i] += fib[i-1] ;
22 }
23 }
24
25 int main()
26 {
27 InitFIB() ;
28
29 while( cin >> inn )
30 {
31 cout << fib[inn] << endl ;
32 }
33
34 return 0 ;
35 }