#P5091. 【模板】扩展欧拉定理

【模板】扩展欧拉定理

Description

You are given three positive integers aa, mm, and bb. You need to compute: abmodma^b \bmod m.

Input Format

One line with three integers, a,m,ba,m,b.

Output Format

Output one integer representing the answer.

2 7 4
2
998244353 12345 98765472103312450233333333333
5333

Hint

Pay attention to the input format: a,m,ba,m,b represent the base, the modulus, and the exponent, in this order.

[Sample 11 Explanation]
24mod7=22^4 \bmod 7 = 2.

[Constraints]
For 100%100\% of the testdata, 1a1091\le a \le 10^9, 1b10200000001\le b \le 10^{20000000}, 1m1081\le m \le 10^8.

Translated by ChatGPT 5