SHARE
TWEET

Untitled

The_Law Jun 19th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top