Advertisement
Salehisayev

BAX

Mar 9th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. #define pii pair<int , int>
  6. #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  7. #define MAXX 10005
  8.  
  9. ll a , b , c;
  10.  
  11. ll powmod(ll a , ll n , ll m){//a uste n qaliq m
  12. if(!n) return 1; //eded ustu sifir 1 olur insuzda
  13. if(n % 2 == 0) return powmod((a * a) % m , n / 2 , m) % m;//n cutdurse a nin kvadrati ustu n
  14. return (a * powmod(a , n - 1 , m)) % m; // tekdirse a * a^n-1
  15. }
  16.  
  17. int main()
  18. {
  19. _FastIO;
  20. cin >> a >> b >> c;
  21. cout << powmod(a , b , c) << endl;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement