#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull multiply(ull a,ull b,ull mod) {
ull ans=0;
while(b) {
if(b&1) ans=(ans+a)%mod;
b>>=1;
a=a*2%mod;
}
return ans%mod;
}
int main() {
ull a,b,mod;
scanf("%lld%lld%lld",&a,&b,&mod);
printf("%llu\n",multiply(a,b,mod));
return 0;
}
不超过 2^64-1的乘法取模 ( C++ )
最新推荐文章于 2021-07-03 15:14:49 发布