#include <bits/stdc++.h>
using namespace std ;
#define ll long long
const ll mod = 0x998776655443322 ;
ll mul(ll a, ll b)
{
a = a % mod ;
b = b % mod ;
ll res = 0 ;
while(b > 0)
{
if(b & 1) res = (res + a) % mod ;
a = (a + a) % mod ;
b >>= 1 ;
}
return res ;
}
int main()
{
ll a = 0x7877665544332211 ;
ll b = 0x7988776655443322 ;
printf("%lld\n", (a % mod) * (b % mod) % mod) ;
printf("%lld\n", mul(a, b)) ;
}
模运算(防止溢出mul)
于 2023-04-27 12:51:34 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)