fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define endl '\n'
  4. #define pi 2 * acos(0.0)
  5. #define ll long long
  6. void IO()
  7. {
  8. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  9. #ifndef ONLINE_JUDGE
  10. freopen("input.txt", "r", stdin);
  11. freopen("output.txt", "w", stdout);
  12. #endif
  13. }
  14.  
  15. const int N = (int)3e2 + 5;
  16. int mod = 1e9 + 7;
  17. ll pw(ll b, ll p)
  18. {
  19. if (p == 0) return 1;
  20. ll sq = pw(b, p / 2);
  21. sq = (sq % mod) * (sq % mod) % mod;
  22.  
  23. if (p & 1)
  24. sq = (sq * (b % mod)) % mod;
  25.  
  26. return sq;
  27. }
  28. int main()
  29. {
  30. IO();
  31. ll a, b, c;
  32. cin >> a >> b >> c;
  33. ll power = pw(a, b);
  34. cout << (power % c) << endl;
  35. }
  36. //
  37. //
Success #stdin #stdout 0s 5628KB
stdin
Standard input is empty
stdout
179648903