https://www.luogu.com.cn/paste/8s8f62vl
#include<bits/stdc++.h>
#define ll long long
#define mxn 200003
#define pb push_back
#define mkp make_pair
#define ld long double
#define umap unordered_map
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rept(i,a,b) for(int i=a;i<b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
#define pq priority_queue
using namespace std;
struct fastmod {
using u64 = uint64_t;
using u128 = __uint128_t;
int f, l; u64 m, d;
fastmod(u64 d): d(d) {
l = 64 - __builtin_clzll(d - 1);
const u128 one = 1;
u128 M = ((one << (64 + l)) + (one << l)) / d;
if(M < (one << 64)) f = 1, m = M;
else f = 0, m = M - (one << 64);
}
friend u64 operator/(u64 n, const fastmod &m) { // get n / d
if (m.f) return u128(n) * m.m >> 64 >> m.l;
else {
u64 t = u128(n) * m.m >> 64;
return (((n - t) >> 1) + t) >> (m.l - 1);
}
}
friend u64 operator%(u64 n, const fastmod &m) { // get n % d
return n - n / m * m.d;
}
};
fastmod md(998244353);
ll a,b;
signed main(){
cin>>a>>b;
cout<<a*b%md;
return 0;
}
标签:fastmod,u64,long,u128,using,快速,define
From: https://www.cnblogs.com/zifanoi/p/18038477