0x01 C 64位整数乘法
link
快速乘板子
没什么要说的,上板子即可
#include <bits/stdc++.h>
using ll = long long;
auto main()->int {
std::cin.tie(nullptr)->sync_with_stdio(false);
auto qmul = [&](ll a, ll b, ll p) {
ll ans = 0;
for (; b; b >>= 1) {
if (b & 1) {
ans = (ans + a) % p;
}
a = (a + a) % p;
}
return ans;
};
ll A, B, P;
std::cin >> A >> B >> P;
std::cout << qmul(A, B, P);
return 0;
}
5min