fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll mu(ll a, ll b, ll m)
  5. {
  6. if (b == 0)
  7. return 1;
  8. if (b == 1)
  9. return a;
  10. int c = mu(a, b / 2, m);
  11. if (b % 2 == 0)
  12. return (c % m * c % m) % m;
  13. if (b % 2 != 0)
  14. return (c % m * c % m * a % m) % m;
  15. }
  16. int main()
  17. {
  18. ll x, y, z;
  19. cin >> x >> y >> z;
  20. cout << mu(x, y, z);
  21. }
  22.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
99223434226224