Advertisement
Khody

Untitled

Feb 27th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <vector>
  6. #include <algorithm>
  7. #include <cmath>
  8. #include <math.h>
  9. #include <set>
  10. #include <map>
  11. #include <queue>
  12. #include <deque>
  13. #include <stack>
  14.  
  15. #define pb push_back
  16. #define ff first
  17. #define ss second
  18. #define sqr(x) (x) * (x)
  19. #define cb(x) (x) * (x) * (x)
  20. #define SIZE 101
  21. #define INF 1e18 + 9
  22.  
  23. using namespace std;
  24.  
  25. typedef long long ll;
  26. typedef long double ld;
  27. typedef pair<int, int> pii;
  28. typedef pair<ll, ll> pll;
  29.  
  30. const int inf = 2e9;
  31. const ll linf = 2e18;
  32.  
  33. template <typename T>
  34. ostream& operator << (ostream& s, vector<T>& v) {
  35.     for (auto el : v) {
  36.         s << el << " ";
  37.     }
  38.     return s;
  39. }
  40.  
  41.  
  42.  
  43. int main() {
  44.     ios_base::sync_with_stdio(0);
  45.     cin.tie(0), cout.tie(0);
  46.     ll mod = 12345;
  47.  
  48.     int n; cin >> n;
  49.     vector<vector<ll>> dp(n + 2, vector<ll>(2));
  50.     dp[0][0] = 1;
  51.  
  52.     for (int i = 1; i <= n + 1; i++) {
  53.         dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
  54.         dp[i][1] = dp[i - 1][0];
  55.         if (i > 1) dp[i][1] += dp[i - 2][0];
  56.         dp[i][0] %= mod;
  57.         dp[i][1] %= mod;
  58.     }
  59.     cout << dp[n + 1][0] << endl;
  60.  
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement