//
// Created by ToroLHZ on 2022/4/2.
//
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, c;
ll ans;
//纯暴力
ll method1(ll x, ll y, ll z) {
ll sum = 1;
ll i;
for (i = 0; i < y; i++) {
sum = (sum * x) % z;
}
return sum;
}
//优化后
ll method2(ll x, ll y, ll z) {
ll sum = 1;
while (y) {
if (y % 2 == 1) sum = sum * x % z;
x = x * x % z;
y = y / 2;
}
return sum;
}
//优化后-他人代码
ll method3(ll m, ll k, ll p) {
ll res = 1 % p, t = m;
while (k) {
if (k & 1) res = res * t % p;
t = t * t % p;
k >>= 1;
}
return res;
}
int main() {
//求解a的b次方再对c取模
a = 123456;
b = 1e8 + 3;
c = 1e9 + 7;
ans = method1(a, b, c);
cout << ans << endl;
ans = method2(a, b, c);
cout << ans << endl;
ans = method3(a, b, c);
cout << ans << endl;
return 0;
}
//936137248
//936137248
//936137248