1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #include <iostream>
using namespace std;
typedef long long LL;
int qmi(int a, int b, int p) { int res = 1 % p; while (b) { if (b & 1) res = (LL)res * a % p; a = (LL)a * a % p; b >>= 1; } return res; }
int main() { int a, b, p; cin >> a >> b >> p; cout << qmi(a, b, p) << endl; return 0; }
|