You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
386 B
21 lines
386 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
typedef long long LL;
|
|
int a, b, p;
|
|
|
|
LL qmi(LL x, LL y, LL p) {
|
|
LL res = 1;
|
|
while (y) {
|
|
if (y & 1) res = res * x % p;
|
|
y >>= 1;
|
|
x = x * x % p;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
int main() {
|
|
scanf("%d %d %d", &a, &b, &p);
|
|
printf("%d^%d mod %d=%lld\n", a, b, p, qmi(a, b, p));
|
|
return 0;
|
|
} |