Files
python/TangDou/AcWing_TiGao/T6/WeiYunSuan/90_1.cpp

19 lines
305 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a, b, p, res;
int main() {
cin >> a >> b >> p;
// 龟速乘
while (b) {
if (b & 1) res = (res + a) % p;
a = (a + a) % p;
b >>= 1;
}
cout << res << endl;
return 0;
}