不开long long
见祖宗👀
洛谷P1226
#include <stdio.h>
#define LL long long
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define scan(x) scanf("%d", &x)
#define sqr(x) (x) * (x)
#define f(i, a, b) for (int i = a; i <= b; i++)
#define pn(x) printf("%d", x)
#define pr1(x) printf("Case %d: ", x)
#define pn1(x) printf("Case %d:\n", x)
#define pr2(x) printf("Case #%d: ", x)
#define pn2(x) printf("Case #%d:\n", x)
#define lowbit(x) (x & (-x))
int quikpower (int a,int b,int p){
LL ans = 1, base = a;
while(b>0){
if(b&1){
ans *= base;
ans %= p;
}
base *= base;
base %= p;
b >>= 1;
}
return (int)ans%p;
}
int main()
{
int a, b, p;
scan(a);
scan(b);
scan(p);
printf("%d^%d mod %d=", a, b, p);
pn(quikpower(a,b,p));
return 0;
}