Advertisement
leminhkt

noname62

Jul 6th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.23 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. // #include<stdio.h>
  3. // #include<windows.h>
  4. // #include<conio.h>
  5. // #include<time.h>
  6. using namespace std;//                                        |\__/,|   (`\
  7. //                                                          _.|o o  |_   ) )
  8. /// ================================ Define Part ==========(((===(((=============
  9. #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
  10. #define F0R(i, a)    FOR (i, 0, a)
  11. #define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
  12. #define R0F(i, a)    ROF (i, 0, a)
  13. #define trav(a, x)   for (auto& a: x)
  14. #define bk        back()
  15. #define ft        front()
  16. #define pb        push_back
  17. #define mp        make_pair
  18. #define lb        lower_bound
  19. #define ub        upper_bound
  20. #define eb        emplace_back
  21. #define rsz       resize
  22. #define ins       insert
  23. #define fus       first
  24. #define sec       second
  25. #define itr       iterator
  26. #define elif      else if
  27. #define elifn     else ifn
  28. #define sz(x)     int(x.size())
  29. #define ifn(x)    if(!(x))
  30. #define sqr(x)    ((x)*(x))
  31. #define all(x)    (x).begin(), (x).end()
  32. #define inpair(x) x.fus >> x.sec
  33. #define oupair(x) x.fus << x.sec
  34. #define whilen(x) while(!(x))
  35.  
  36. typedef long long       ll;        typedef double          db;
  37. typedef map<int, int>   mi;        typedef map<ll, ll>     mll;       typedef map<db, db>     mdb;
  38. typedef pair<int, int>  pi;        typedef pair<ll, ll>    pll;       typedef pair<db, db>    pdb;
  39. typedef set<int>        si;        typedef set<ll>         sll;       typedef set<db>         sdb;
  40. typedef set<pi>         spi;       typedef set<pll>        spll;      typedef set<pdb>        spdb;
  41. typedef vector<string>  vs;        typedef vector<vs>      v2_s;      typedef vector<v2_s>    v3_s;
  42. typedef vector<bool>    vb;        typedef vector<vb>      v2_b;      typedef vector<v2_b>    v3_b;
  43. typedef vector<int>     vi;        typedef vector<vi>      v2_i;      typedef vector<v2_i>    v3_i;
  44. typedef vector<ll>      vll;       typedef vector<vll>     v2_ll;     typedef vector<v2_ll>   v3_ll;
  45. typedef vector<db>      vdb;       typedef vector<vdb>     v2_db;     typedef vector<v2_db>   v3_db;
  46. typedef vector<pi>      vpi;       typedef vector<vpi>     v2_pi;     typedef vector<v2_pi>   v3_pi;
  47. typedef vector<pll>     vpll;      typedef vector<vpll>    v2_pll;    typedef vector<v2_pll>  v3_pll;
  48. typedef vector<pdb>     vpdb;      typedef vector<vpdb>    v2_pdb;    typedef vector<v2_pdb>  v3_pdb;
  49.  
  50. /// ================================ Independent  Functions ================================
  51. template<typename T>inline T maximize (T &a, T b) { return a = max(a, b); }
  52. template<typename T>inline T minimize (T &a, T b) { return a = min(a, b); }
  53. template<typename T>inline T gcd (T a, T b) { while (b != 0) swap(b, a %= b); return a; }
  54. template<typename T>inline T lcm (T a, T b) { return a/gcd(a, b)*b; }
  55. template<typename T>inline string tostr (T x)      { stringstream ss; ss << x; return ss.str(); }
  56. template<typename T>inline T      tonum (string x) { stringstream ss(x); T n; ss >> n; return n; }
  57. template<typename T>inline T pct  (T x)      { return __builtin_popcount(x); }
  58. template<typename T>inline T bits (T x)      { return 31 - __builtin_clz(x); }
  59. template<typename T>inline T cdiv (T a, T b) { return a/b + (a >= 0 && a%b); }
  60. template<typename T>inline bool bitGet   (T  x, int bit)/* ___/| */{ return T(1) & (x >> bit); }
  61. template<typename T>inline void bitSet   (T &x, int bit)/* \o.O| */{ x |=  (T(1) << bit); }
  62. template<typename T>inline void bitReset (T &x, int bit)/* (___) */{ x &= ~(T(1) << bit); }
  63. template<typename T>inline void bitFlip  (T &x, int bit)/*   U   */{ x ^=  (T(1) << bit); }
  64. template<typename T>inline void bitMake  (T &x, int bit, bool v)   { x ^=  (T(1) << bit) & (-v ^ x); }
  65. template<typename T>inline void writeSigned (T x) {if (x < 0) putchar('-'), x = -x; writeUnsign(x); }
  66. template<typename T>inline void getString  (T& s) {char c;while(c=getchar(),c==' '||c=='\n'||c=='\t');s.clear();s.pb(c);while(c=getchar(),c!=EOF&&c!=' '&&c!='\n'&&c!='\t')s.pb(c);}
  67. template<typename T>inline void getSigned  (T& n) {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign(c=='-');if(sign)c=getchar();n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';if(sign)n=-n;}
  68. inline int    readint()    { int x;    return getSigned(x), x; }
  69. inline ll     readll()     { ll  x;    return getSigned(x), x; }
  70. inline string readstring() { string s; return getString(s), s; }
  71. inline void unsyncIO()         { ios_base::sync_with_stdio(0); cin.tie(0); }
  72. inline void setIn   (string s) { freopen(s.c_str(), "r", stdin);           }
  73. inline void setOut  (string s) { freopen(s.c_str(), "w", stdout);          }
  74.  
  75. /// ================================ Dependent  Functions ================================
  76. const db PI    = acos(-1);
  77. const ll LINF  = (1LL << 60); /// 1e18                                                                                                                                                                                                                                                    ,,__
  78. const int INF  = (1 << 30);   /// 1e9                                                                                                                                                                                                                                                   c''   )?   oink oink im so cute <3
  79. const int LIM  = (1 << 24);   /// 1e7                                                                                                                                                                                                                                                     ''''
  80. const int LOVE = 1411;
  81. const int MOD  = 1e9 + 7;
  82.  
  83. /// ================================ Main part ================================
  84.  
  85. v2_ll operator*(v2_ll a, v2_ll b){
  86.     int m = sz(a), n = sz(a[0]), k = sz(b[0]);
  87.     v2_ll c(m, vll(k, 0));
  88.     F0R(i, m)
  89.         F0R(j, k)
  90.             F0R(l, n)
  91.                 c[i][j] += ((a[i][l]%MOD)*(b[l][j]%MOD))%MOD;
  92.     return c;
  93. }
  94.  
  95. template<typename T> T power(T x, ll n){
  96.     if(n == 1) return x;
  97.     T temp = power(x, n/2);
  98.     if(n%2)
  99.         return temp*temp*x;
  100.     else
  101.         return temp*temp;
  102. }
  103.  
  104. int main(){
  105.     v2_ll a = {{0, 1}, {1, 1}},
  106.           b = {{0, 1}};
  107.     ll n; cin >> n;
  108.     v2_ll c = b*power(a, n);
  109.     cout << c[0][0];
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement