#include<bits/stdc++.h> using namespace std; long long b, a, p, k, ans = 1, c; int main() { scanf("%d%d%d", &b, &p, &k); a = b; c = p; while (p > 0) { if (p % 2 != 0) ans = ans * b%k; b = b * b % k; p = p >> 1; } printf("%lld %lld mod %lld=%lld", a, c, k, ans%k); return 0; }
|