fork download
  1. /*
  2.   school: High School for Gifted Students, University of Science;
  3.   author: Khoi
  4.  */
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7.  
  8. template <class T>bool maximize(T &a, const T &b) {if (a < b) {a = b;return true;}return false;}
  9. template <class T>bool minimize(T &a, const T &b) {if (a > b) {a = b;return true;}return false;}
  10. template <class T> istream& operator>> (istream& in, vector <T>& a){ for (auto &x: a){ in >> x; } return in; }
  11.  
  12. #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
  13. #define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
  14. #define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
  15. #define db(...) cerr << "[" << #__VA_ARGS__ << ": ", debug(__VA_ARGS__), cerr << "\n";
  16. #define ll long long
  17. #define fi first
  18. #define se second
  19.  
  20. /* Author: Khoi Pham Phuc Minh */
  21.  
  22. /** END OF TEMPLATE. DRINK A CUP OF TIGERSUGAR BEFORE READING MY CODE. **/
  23.  
  24. const int MAXN = 2e5 + 5;
  25. const int m = 1e9 + 7;
  26.  
  27. void algovate();
  28.  
  29. int main(void) {
  30. #ifdef ONLINE_JUDGE
  31. // freopen("tenbai.inp", "r", stdin);
  32. // freopen("tenbai.out", "w", stdout);
  33. #endif
  34. cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
  35. int ntest = 1;
  36. //cin >> ntest;
  37. REP(gspmk, ntest) {
  38. // cout << "Case #" << gspmk << ": ";
  39. algovate();
  40. }
  41. #ifdef gspmk_algovate_local
  42. auto end = chrono::steady_clock::now();
  43. cout << endl;
  44. cout << "Excution time : " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
  45. #endif
  46. return (0^0);
  47. }
  48.  
  49. ll n;
  50.  
  51. ll mu(ll a, ll b) {
  52. ll ans = 1;a %= m;
  53. while (b > 0) { if (b & 1) ans = (ans * a) % m; a = (a * a) % m; b >>= 1; }
  54. return ans;
  55. }
  56.  
  57. void algovate(void) {
  58. cin >> n;
  59. ll k = (mu((n + 1) / 2, (n + 1) / 2) * mu(n / 2, n / 2)) % m, d = (mu(n / 2, (n + 1) / 2) * mu((n + 1) / 2, n / 2)) % m;
  60. cout << (k + d) % m <<"\n";
  61. }
  62.  
  63. /*** BUBBLE TEA IS GREAT. MY CODE IS AMAZING :D ***/
  64.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
2