Advertisement
The_Law

Untitled

Jun 19th, 2017
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. vector< vector<int> > dp;
  6.  
  7. int main()
  8. {
  9.     freopen("j.in", "r", stdin);
  10.     int n;
  11.     cin >> n;
  12.  
  13.     dp.resize(n, vector<int>(2, 0));
  14.  
  15.     dp[0][0] = 1;
  16.     dp[0][1] = 1;
  17.  
  18.     for (int i = 1; i < n; ++i)
  19.         dp[i][0] = dp[i - 1][0] + dp[i - 1][1], dp[i][1] = dp[i - 1][0];
  20.  
  21.     cout << dp[n - 1][0] + dp[n - 1][1];
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement