fork download
  1. #pragma GCC optimize("O3,unroll-loops")
  2. #include <bits/stdc++.h>
  3. //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
  4. using namespace std;
  5.  
  6. #define FOR(i, a, b) for(LL i = (a); i < (b); i++)
  7. #define REP(i, a, b) for(LL i = (a); i <= (b); i++)
  8. #define FORD(i, a, b) for(LL i = (a); i > (b); i--)
  9. #define REPD(i, a, b) for(LL i = (a); i >= (b); i--)
  10. #define SZ(a) (int((a).size()))
  11. #define ALL(a) (a).begin(), (a).end()
  12. #define ALLD(a) (a).rbegin(), (a).rend()
  13. #define PB push_back
  14. #define MP make_pair
  15. #define LL long long
  16. #define ULL unsigned long long
  17. #define LD long double
  18. #define PLL pair<LL, LL>
  19. #define FI first
  20. #define SE second
  21. #define VTLL vector<long long>
  22. #define VTLD vector<long double>
  23. #define TOLOWER(s) transform((s).begin(), (s).end(), (s).begin(), ::tolower)
  24. #define TOUPPER(s) transform((s).begin(), (s).end(), (s).begin(), ::toupper)
  25. #define MIN(v) *min_element((v).begin(), (v).end())
  26. #define MAX(v) *max_element((v).begin(), (v).end())
  27. #define LB(c, x) distance((c).begin(), lower_bound(ALL(c), (x)))
  28. #define UB(c, x) distance((c).begin(), upper_bound(ALL(c), (x)))
  29. #define UNIQUE(x) sort(ALL(x)), x.erase(unique(ALL(x)), x.end()), x.shrink_to_fit()
  30. template <typename T>
  31. T SUM(const vector<T> a) {
  32. T sum = 0;
  33. for (T v : a) sum += v;
  34. return sum;
  35. }
  36. #define MS(a, x) memset(a, x, sizeof(a))
  37. #define FID(x) fixed << setprecision(x)
  38. #define MASK(i) (1LL << (i))
  39. #define BIT(x, i) (((x) >> (i)) & 1)
  40. #define ___Dang_Nhat_Tinh___ signed main()
  41. #define TIME (1.0 * clock() / CLOCKS_PER_SEC)
  42. #define FILE(name) if (fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
  43.  
  44. template <typename T>
  45. void debug_val(const T &val) { cerr << val; }
  46.  
  47. template <typename T1, typename T2>
  48. void debug_val(const pair<T1, T2> &p) {
  49. cerr << "(";
  50. debug_val(p.first);
  51. cerr << ", ";
  52. debug_val(p.second);
  53. cerr << ")";
  54. }
  55.  
  56. template <typename T>
  57. void debug_val(const vector<T> &v) {
  58. cerr << "[";
  59. for (size_t i = 0; i < v.size(); ++i) {
  60. if (i) cerr << ", ";
  61. debug_val(v[i]);
  62. }
  63. cerr << "]";
  64. }
  65.  
  66. template <typename T>
  67. void debug_val(const set<T> &s) {
  68. cerr << "{";
  69. bool first = true;
  70. for (const auto &x : s) {
  71. if (!first) cerr << ", ";
  72. debug_val(x);
  73. first = false;
  74. }
  75. cerr << "}";
  76. }
  77.  
  78. template <typename K, typename V>
  79. void debug_val(const map<K, V> &m) {
  80. cerr << "{";
  81. bool first = true;
  82. for (const auto &kv : m) {
  83. if (!first) cerr << ", ";
  84. debug_val(kv);
  85. first = false;
  86. }
  87. cerr << "}";
  88. }
  89.  
  90. template<typename T>
  91. void dbg(T x) { debug_val(x); cerr << '\n'; }
  92.  
  93. template<typename T, typename... Args>
  94. void dbg(T x, Args... args) {
  95. debug_val(x); cerr << ", ";
  96. dbg(args...);
  97. }
  98. #define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "] = ", dbg(__VA_ARGS__)
  99.  
  100. LL lcm(LL a, LL b) { return a / __gcd(a, b) * b; }
  101. LL max(LL a, LL b) { return a > b ? a : b; }
  102. LL min(LL a, LL b) { return a < b ? a : b; }
  103. const LL MAX = 1e6 + 7;
  104. const LL MOD = 1e9 + 7;
  105. const LL LIM = 1e4 + 5;
  106. bool Prime[MAX];
  107. void sieve(LL n = MAX) {
  108. MS(Prime, true);
  109. Prime[0] = Prime[1] = false;
  110. for (LL i = 2; i*i <= n; i++) {
  111. if (Prime[i]) {
  112. for (LL j = i*i; j <= n; j += i) {
  113. Prime[j] = false;
  114. }
  115. }
  116. }
  117. }
  118.  
  119. LL mul(LL a, LL n, LL mod){
  120. LL res = a, ans = 0;
  121. while(n){
  122. if(n & 1) ans = (ans + res) % mod;
  123. res = (res+res) % mod;
  124. n /= 2;
  125. }
  126. return ans;
  127. }
  128. LL po(LL a, LL n, LL mod) {
  129. LL res=a, ans=1;
  130. while(n){
  131. if(n & 1) ans = mul(ans, res, mod)% mod;
  132. res=mul(res,res, mod)% mod;
  133. n/=2;
  134. }
  135. return ans;
  136. }
  137.  
  138. LL phi(LL n) {
  139. int res = n;
  140. for (int i = 2; i * i <= n; ++i) {
  141. if (n % i == 0) {
  142. while (n % i == 0) {
  143. n /= i;
  144. }
  145. res -= res / i;
  146. }
  147. }
  148. if (n != 1) {
  149. res -= res / n;
  150. }
  151. return res;
  152. }
  153.  
  154.  
  155. LL tran(string s, LL mod) {
  156. LL sum = 0;
  157. FOR(i, 0, SZ(s)) {
  158. sum = (sum * 10 + (s[i] - 48)) % mod;
  159. }
  160. return sum;
  161. }
  162.  
  163. ___Dang_Nhat_Tinh___ {
  164. ios_base::sync_with_stdio(false);
  165. cin.tie(nullptr);
  166. cout.tie(nullptr);
  167.  
  168. string a, b, c; cin >> a >> b >> c;
  169. LL aa = tran(a, MOD), bb = tran(b, MOD - 1), cc = tran(c, phi(MOD - 1));
  170. cout << po(aa, po(bb, cc, MOD - 1), MOD);
  171.  
  172. cerr << "Time elapsed: " << TIME << " .s\n";
  173. return (0 ^ 0);
  174. }
Success #stdin #stdout #stderr 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Time elapsed: 0.004789 .s