正文
增加 20 行删除 20 行
37 行未改动38394041424344454647484950515253545556575813 行未改动727374757677787980818283848586878889909192939495969798991001011021032 行未改动10610710810911011111211311411511611711811912012112212312440 行未改动1651661671681691701711721731741758 行未改动18418518618718818919019119218 行未改动37 行未改动## FastMod```cpptypedef long long ll; typedef __int128 lll;struct FastMod {int m; ll b;void init(int _m) { m = _m; b = ((lll)1<<64) / m; }int operator() (ll a) {ll q = ((lll)a * b) >> 64;a -= q * m;if (a >= m) a -= m;return a;}} Mod;int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }int mul(int a, int b) { return Mod(1ll * a * b); }template <typename ...Args>int mul(int a, Args ...b) { return mul(a, mul(b...)); }``````cpp13 行未改动```cppnamespace joke3579 {// 返回值快读template <typename __T>inline __T r() {__T ans = 0; char ch = getchar(); bool sgn = true;while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();if (ch == '-') sgn = false, ch = getchar();while (ch >='0' && ch <='9') ans = (ans<<1) + (ans<<3) + (ch^48), ch = getchar();return sgn? ans : -ans;}// 指定地点快读template <typename __T>inline void get(__T & dest) {dest = 0; char ch = getchar(); bool sgn = false;while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();if (ch == '-') sgn = true, ch = getchar();while (ch >='0' && ch <='9') dest = (dest<<1) + (dest<<3) + (ch^48), ch = getchar();if (sgn) dest = -dest;}// 闲来无事写个字符串快读inline void getStr(char * dest, const char endAt) {while (*(dest-1) != endAt) *dest++ = getchar();*--dest = '\0';}// 扩欧template <typename __T>inline __T exgcd(__T a, __T b, __T &n, __T &m) {if (b == 0) {n = 1, m = 0;return a;}2 行未改动return nowgcd;}// 线性同余方程template <typename __T>inline bool lion(__T a, __T b, __T c, __T &n, __T &m) {int nowgcd = exgcd(a,b,n,m);if (c % nowgcd != 0) return false;int tmp = c / nowgcd;n *= tmp;m *= tmp;return true;}// 线性算欧拉函数template <typename __T>inline void calcPhi(int *phi, int max) {int prime[max+2], num = 0;bool isPrime[max+2];memset(prime, 0, sizeof prime);memset(isPrime, true, sizeof prime);40 行未改动return ans;}// 线性算逆元template <typename __T>inline void calcInv(__T * inv, __T max, __T mod) {inv[1] = 1;for (int i = 2; i <= max; i++)inv[i] = 1ll*(mod - mod/i) * inv[mod % i] % mod;}// 费马小定理算逆元template <typename __T>8 行未改动}// BKDR Hashinline hashint calcHash(char * s) {register hashint hash = 0;while (hashint now = (hashint)*str++)hash = hash* 131 + now;return hash;}// KMP板子18 行未改动37 行未改动38394041424344454647484950515253545556575813 行未改动727374757677787980818283848586878889909192939495969798991001011021032 行未改动10610710810911011111211311411511611711811912012112212312440 行未改动1651661671681691701711721731741758 行未改动18418518618718818919019119218 行未改动37 行未改动## FastMod```cpptypedef long long ll; typedef __int128 lll;struct FastMod {int m; ll b;void init(int _m) { m = _m; b = ((lll)1<<64) / m; }int operator() (ll a) {ll q = ((lll)a * b) >> 64;a -= q * m;if (a >= m) a -= m;return a;}} Mod;int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }int mul(int a, int b) { return Mod(1ll * a * b); }template <typename ...Args>int mul(int a, Args ...b) { return mul(a, mul(b...)); }``````cpp13 行未改动```cppnamespace joke3579 {// 返回值快读template <typename __T>inline __T r() {__T ans = 0; char ch = getchar(); bool sgn = true;while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();if (ch == '-') sgn = false, ch = getchar();while (ch >='0' && ch <='9') ans = (ans<<1) + (ans<<3) + (ch^48), ch = getchar();return sgn? ans : -ans;}// 指定地点快读template <typename __T>inline void get(__T & dest) {dest = 0; char ch = getchar(); bool sgn = false;while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();if (ch == '-') sgn = true, ch = getchar();while (ch >='0' && ch <='9') dest = (dest<<1) + (dest<<3) + (ch^48), ch = getchar();if (sgn) dest = -dest;}// 闲来无事写个字符串快读inline void getStr(char * dest, const char endAt) {while (*(dest-1) != endAt) *dest++ = getchar();*--dest = '\0';}// 扩欧template <typename __T>inline __T exgcd(__T a, __T b, __T &n, __T &m) {if (b == 0) {n = 1, m = 0;return a;}2 行未改动return nowgcd;}// 线性同余方程template <typename __T>inline bool lion(__T a, __T b, __T c, __T &n, __T &m) {int nowgcd = exgcd(a,b,n,m);if (c % nowgcd != 0) return false;int tmp = c / nowgcd;n *= tmp;m *= tmp;return true;}// 线性算欧拉函数template <typename __T>inline void calcPhi(int *phi, int max) {int prime[max+2], num = 0;bool isPrime[max+2];memset(prime, 0, sizeof prime);memset(isPrime, true, sizeof prime);40 行未改动return ans;}// 线性算逆元template <typename __T>inline void calcInv(__T * inv, __T max, __T mod) {inv[1] = 1;for (int i = 2; i <= max; i++)inv[i] = 1ll*(mod - mod/i) * inv[mod % i] % mod;}// 费马小定理算逆元template <typename __T>8 行未改动}// BKDR Hashinline hashint calcHash(char * s) {register hashint hash = 0;while (hashint now = (hashint)*str++)hash = hash* 131 + now;return hash;}// KMP板子18 行未改动