提交时间:2023-11-11 10:49:55
运行 ID: 109795
#include <bits/stdc++.h> #define int long long using namespace std; int ksm(int a,int b,int p) { int res = 1,t = a % p; while (b >= 1) { if (b & 1) res = (res * t) % p; t = (t * t) % p;b >>= 1; } return res; } signed main() { int a,b,p; cin >> a >> b >> p; printf("%lld^%lld mod %lld=%lld",a,b,p,ksm(a,b,p)); return 0; }