1629 곱셈
코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;
long long A, B, C;
long long result = 1;
int main() {
cin >> A >> B >> C;
while (B != 0) {
if (B % 2 == 1) {
result = (result * A) % C;
}
A = (A * A) % C;
B /= 2;
}
cout << result % C;
}