快速乘(利用数的二进制进行计算)
#include<iostream>
using namespace std;
typedef long long ll;
ll q_mul(ll a, ll b, ll p) {
ll ret = 0;
while (b) {
if (b&1)(ret += a)%=p;
b>>=1;
(a<<=1)%=p;
}
return ret;
}
int main() {
ios::sync_with_stdio(0);
ll a, b, p;
cin >> a >> b >> p;
cout << q_mul(a, b, p);
}