Advertisement
yuawn

algo2017_week11_fabonacci

Dec 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define pb push_back
  4. #define mp make_pair
  5. #define fo(n) for(int i=0;i<n;i++)
  6. #define fos(o,n) for(int i=o;i<=n;i++)
  7.  
  8. int a[400];
  9.  
  10. void build(){
  11.     fos( 2 , 400 ) a[i] = a[i - 1] + a[i - 2];
  12. }
  13.  
  14. int main(){
  15.    
  16.     int T;
  17.     cin >> T;
  18.    
  19.     a[0] = 0;
  20.     a[1] = 1;
  21.    
  22.     build();
  23.    
  24.     while( T-- ){
  25.         int n;
  26.         cin >> n;
  27.         cout << a[n] << endl;
  28.     }
  29.    
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement