#P1226. 【模板】快速幂

【模板】快速幂

Description

Given three integers aa, bb, pp, compute abmodpa^b \bmod p.

Input Format

The input contains a single line with three integers representing aa, bb, pp.

Output Format

Output one line with the string a^b mod p=s, where aa, bb, pp are the given values and ss is the result.

2 10 9

2^10 mod 9=7

Hint

Sample Explanation:

210=10242^{10} = 10241024mod9=71024 \bmod 9 = 7.

Constraints:

For 100%100\% of the testdata, it is guaranteed that 0a,b<2310 \leq a, b < 2^{31}, a+b>0a + b > 0, 2p<2312 \leq p \lt 2^{31}.

Translated by ChatGPT 5