std::__int114514

· · 个人记录

std::__int114514,压行后仅有15KB!

本人蒟蒻,部分代码是从网上复制借鉴的

string旧版

最近更新

2023-12-30

改进除法

2023-12-24

参考了最优解里的 FFT 算法(常数貌似更小?)

性能测试器:

#include<bits/stdc++.h>
//#pragma GCC optimize(3,"Ofast","inline")
//#pragma G++ optimize(3,"Ofast","inline")
#include"int114514"
using namespace std;
int main() {

    __int114514 a=123,b=456;
    for(int i=1; i<=16; i++) {
        a=a*a, b=b*b;
        cout << "len:" << a.len() << " " << b.len() << endl;
        auto start = chrono::steady_clock::now();
        __int114514 c = __fft__mul(a,b);
        auto end = chrono::steady_clock::now();
        cout << "FFT time:" << (chrono::duration_cast<chrono::microseconds>(end-start)).count() << "  ";

        start = chrono::steady_clock::now();
        __int114514 d = __nofft__mul(a,b);
        end = chrono::steady_clock::now();
        cout << "No FFT time:" << (chrono::duration_cast<chrono::microseconds>(end-start)).count() << "\n";
//      if(a.len() < 50) {
//          cout << "FFT val:" << c << "\nNo FFT val:" << d << "\n";
//      }
    }
    return 0;
}

2023-12-16

2023-12-15

2023-9-23

2023-8-19

2023-8-20

使用方法

支持的运算:

+$,时间复杂度 $O(n) -$,时间复杂度 $O(n) \times$,时间复杂度 $O(n \log n)

注:n 很小时使用朴素压位乘,约为 \frac{n^2}{81}

\div$,时间复杂度 $O(n^2) \%$,时间复杂度 $O(n^2) $|$(按位或),时间复杂度 $O(n^2)$,常数大,没有除法快 $\sim$(按位取反),时间复杂度 $O(n)$,很快,~~底层就是改变符号再减1~~ $pow()$,时间复杂度 $O(n^2 \log m) abs()$,时间复杂度 $O(1)

例:

__int114514 a,b;
cin >> a >> b;
cout << a+b;

完整代码(建议放在一个文件里,通过#include调用)

/*
基于vector储存,速度快
不支持小数,但支持负数
*/
#include<bits/stdc++.h>
const double PI=acos(-1.0);
#define _1e9 1000000000LL
#define _1e18 1000000000000000000LL
#if __cplusplus < 201103
#define noexcept throw()
#endif
namespace std {
    namespace __fft__base {
        const int N=1<<20;
        inline int bceil(int x) {
            return (x == 1 || x == 0) ? x : (1 << (__lg(x - 1) + 1));
        }
        namespace f_f_t {
            const double Pi_2 = acos(-1.0) / 2;
            complex<double> w[N>>3];
            int init_l;
            inline void init(int l) {
                if (l <= init_l)
                    return;
                int t = __lg(l - 1);
                l = 1 << t, *w = complex<double>(1.0, 0.0), init_l = l << 1;
                for (int i = 1; i < l; i <<= 1)
                    w[i] = polar(1.0, Pi_2 / i);
                for (int i = 1; i < l; ++i)
                    w[i] = w[i & (i - 1)] * w[i & -i];
            }
            void dif(complex<double> *f, int &L) {
                for (int l = L >> 1, r = L; l; l >>= 1, r >>= 1) {
                    for (complex<double> *j = f, *o = w; j != f + L; j += r, ++o) {
                        for (complex<double> *k = j; k != j + l; ++k) {
                            complex<double> x = *k, y = k[l] * *o;
                            *k = x + y, k[l] = x - y;
                        }
                    }
                }
            }
            void dit(complex<double> *f, int &L) {
                for (int l = 1, r = 2; l < L; l <<= 1, r <<= 1) {
                    for (complex<double> *j = f, *o = w; j != f + L; j += r, ++o) {
                        for (complex<double> *k = j; k != j + l; ++k) {
                            complex<double> x = *k, y = k[l];
                            *k = x + y, k[l] = (x - y) * conj(*o);
                        }
                    }
                }
            }
            void Conv(double *f, int &lim, double *g) {
                complex<double> *F = (complex<double>*)f, *G = (complex<double>*)g;
                int l = lim >> 1;
                init(l), dif(F, l), dif(G, l);
                double fx = 2.0 / lim, fx2 = 0.5 / lim;
                F[0] = (F[0] * G[0] + 2 * F[0].imag() * G[0].imag()) * fx, F[1] = F[1] * G[1] * fx;
                for (int k = 2, m = 3; k < l; k <<= 1, m <<= 1) {
                    for (int i = k, j = i + k - 1; i < m; ++i, --j) {
                        complex<double> oi = (F[i] + conj(F[j])), hi = (F[i] - conj(F[j]));
                        complex<double> Oi = (G[i] + conj(G[j])), Hi = (G[i] - conj(G[j]));
                        complex<double> r0 = oi * Oi - hi * Hi * ((i & 1) ? -w[i >> 1] : w[i >> 1]), r1 = Oi * hi + oi * Hi;
                        F[i] = (r0 + r1) * fx2, F[j] = conj(r0 - r1) * fx2;
                    }
                }
                dit(F, l);
            }
        }
        double F[N>>1], G[N>>1];
        char buf[N<<1];
        void main(char* bga, char* eda, char* bgb, char* edb, string &ans) {
            auto radX = [](char* bg, char* ed, double* out) {
                char *edr = bg + 4, *pos = ed;
                for(; pos>edr; pos-=4) *out++ = *(pos-4)*1000+*(pos-3)*100+*(pos-2)*10+*(pos-1)-53328;
                return *out++ = stod(string(bg, pos)), out;
            };
            int n = radX(bga, eda, F) - F, m = radX(bgb, edb, G) - G, lim = max(8, bceil(n + m - 1));
            fill(F + n, F + lim, 0.0), fill(G + m, G + lim, 0.0), f_f_t::Conv(F, lim, G);

            struct ict {
                int num[10000];
                ict() {
                    int j = 0;
                    for(int e0 = (48 << 0); e0 < (58 << 0); e0 += (1 << 0))
                        for(int e1 = (48 << 8); e1 < (58 << 8); e1 += (1 << 8))
                            for(int e2 = (48 << 16); e2 < (58 << 16); e2 += (1 << 16))
                                for(int e3 = (48 << 24); e3 < (58 << 24); e3 += (1 << 24))
                                    num[j++] = e0^e1^e2^e3;
                }
            } ot;
            int o = (n + m - 2), *ed = (int*)buf + o, *c = ed;
            unsigned long long u = 0;
            for(int p = 0; p < o; ++p)
                u += (unsigned long long)(F[p] + 0.5), *--c = ot.num[u % 10000u], u /= 10000u;
            ans = to_string(u + (unsigned long long)(F[o] + 0.5));
            for(char* p=reinterpret_cast<char*>(c); p<reinterpret_cast<char*>(ed); p++) ans += *p;
        }
    };
    const double PI=acos(-1.0);
    class __int114514 {   //高精度类
        private:
            //比较
            inline bool cmp(const vector<long long> &a, const vector<long long> &b) const noexcept {
                if(a.size() > b.size()) return 1;
                if(a.size() < b.size()) return 0;
                for(int i=a.size()-1; ~i; --i) {
                    if(a[i] > b[i]) return 1;
                    if(a[i] < b[i]) return 0;
                }
                return 1;
            }

            //高精度乘除低精度
            vector<long long> chu_int(const vector<long long> &a, int b) const noexcept {
                long long t=0;
                vector<long long>c;
                for (int i=a.size()-1; ~i; --i) {
                    t = t*_1e9+a[i];
                    c.push_back(t/b);
                    t %= b;
                }
                reverse(c.begin(), c.end());
                while (c.size() > 1 && c.back() == 0) c.pop_back();
                return c;
            }
            int mod_int(vector<long long> &a, int b) noexcept {
                long long t=0;
                vector<long long>c;
                for (int i=a.size()-1; ~i; --i) {
                    t = t*_1e9+a[i];
                    t %= b;
                }
                return t;
            }
            vector<long long> cheng_int(const vector<long long> &a,int b) const noexcept {
                long long t=0;
                vector<long long>c;
                for(int i=0; i<(int)a.size(); ++i) {
                    t += a[i]*b;
                    c.push_back(t%_1e9);
                    t /= _1e9;
                }
                while(t) {
                    c.push_back(t%_1e9);
                    t /= _1e9;
                }
                return c;
            }

            //高精度计算代码
            vector<long long> add(const vector<long long> &a, const vector<long long> &b) const noexcept {
                vector<long long> c;
                for (long long i = 0, t = 0; i < (int)a.size() || i < (int)b.size() || t; ++i) {
                    if (i < (int)a.size()) t += a[i];
                    if (i < (int)b.size()) t += b[i];
                    c.push_back(t % _1e9);
                    t /= _1e9;
                }
                return c;
            }
            vector<long long> sub(const vector<long long> &a,const vector<long long> &b) const noexcept {
                vector<long long> c;
                long long t=0;
                for(int i=0; i<(int)a.size(); ++i) {
                    t+=a[i];
                    if(i<(int)b.size()) t-=b[i];
                    c.push_back((t+_1e9)%_1e9);
                    if(t<0) t=-1;
                    else t=0;
                }
                while(c.size()>1 && c.back()==0) c.pop_back();
                return c;
            }
            vector<long long> cf(const vector<long long> &a,const vector<long long> &b) const noexcept {
                vector<long long> c(a.size()+b.size()+1);
                for(int i=0; i<(int)a.size(); ++i) {
                    for(int j=0; j<(int)b.size(); ++j) {
                        int k=i+j;
                        c[k]+=a[i]*b[j], c[k+1]+=c[k]/_1e9, c[k]%=_1e9;
                    }
                }
                while(c.size()>1 && !c.back()) c.pop_back();
                return c;
            }
            inline bool chu_cmp(const long long *a, const int &a_h, const int &a_t, const int *b, const int &bsize) const noexcept {
                if(a_t-a_h+1 > bsize) return 1;
                if(a_t-a_h+1 < bsize) return 0;
                for(int i=bsize-1; ~i; --i) {
                    if(a[a_h+i] > b[i]) return 1;
                    if(a[a_h+i] < b[i]) return 0;
                }
                return 1;
            }
            vector<long long> chu(const vector<long long> &x, const vector<long long> &y) const noexcept {
                vector<long long> c;
                long long f[x.size()+5]; // 被除数缓冲区
                int _head=x.size()+2, _tail=x.size()+1;
                int g[y.size()+5]; // 试商缓冲区
                int f_len;
                long long ct;
                if (x.size() < y.size()) {
                    c.push_back(0);
                    return c;
                }
                for(int i=x.size()-1; ~i; --i) { // 这里比较复杂,新手不建议学习
                    f[--_head] = x[i];
                    if(_tail-_head+1 >= (int)y.size()) {
                        int l,r,p=0;
                        // 用首几位相除估计商的范围
                        if(_tail-_head+1 == y.size()) l=f[_tail]/(y.back()+1), r=(f[_tail]+1)/y.back();
                        else {
                            if(y.size() >= 3) {
                                __int128 ff = (__int128(f[_tail]*_1e9+f[_tail-1])*_1e9+f[_tail-2])*_1e9+f[_tail-3];
                                __int128 gg = (__int128(y.back()*_1e9+y[y.size()-2])*_1e9+y[y.size()-3]);
                                l=ff/(gg+1), r=min((long long)((ff+1)/gg),999999999LL);
                            } else l=(f[_tail]*_1e9+f[_tail-1])/(y.back()+1), r=min((f[_tail]*_1e9+f[_tail-1]+1)/y.back(),999999999LL);
                        }

                        while(l <= r) { // 二分试商

                            int mid = (l+r) >> 1;

                            f_len=0, ct=0; // 高精乘低精(试商)
                            for(int i=0; i<(int)y.size(); ++i) ct+=y[i]*mid, g[f_len++]=ct%_1e9, ct/=_1e9;
                            while(ct) g[f_len++]=ct%_1e9, ct/=_1e9;

                            if(chu_cmp(f,_head,_tail,g,f_len)) p=mid, l=mid+1;
                            else r=mid-1;
                        }

                        for(int j=_head; j<_head+(int)y.size(); ++j) { // 减
                            f[j] -= y[j-_head]*p;
                            if(f[j] < 0)
                                f[j+1]-=(-f[j])/_1e9+((-f[j])%_1e9>0), f[j]=(f[j]+_1e18)%_1e9;
                        }

                        c.push_back(p);
                        while (_head <= _tail && f[_tail] == 0) --_tail;
                    } else c.push_back(0);
                }
                reverse(c.begin(), c.end());
                while (c.size() > 1 && c.back() == 0) c.pop_back();
                return c;
            }
            vector<long long> mod(vector<long long> &x, vector<long long> &y) noexcept {
                // 原理和除法差不多,就不写注释了
                long long f[x.size()+5];
                int _head=x.size()+2,_tail=x.size()+1;
                int g[y.size()+5];
                int f_len;
                long long ct;
                if(x.size()<y.size()) return x;
                for(int i=x.size()-1; ~i; --i) {
                    f[--_head]=x[i];
                    if(_tail-_head+1>=(int)y.size()) {
                        int l,r,p=0;
                        if(_tail-_head+1==y.size())l=f[_tail]/(y.back()+1),r=(f[_tail]+1)/y.back();
                        else {
                            if(y.size()>=3) {
                                __int128 ff=(__int128(f[_tail]*_1e9+f[_tail-1])*_1e9+f[_tail-2])*_1e9+f[_tail-3];
                                __int128 gg=(__int128(y.back()*_1e9+y[y.size()-2])*_1e9+y[y.size()-3]);
                                l=ff/(gg+1),r=min((long long)((ff+1)/gg),999999999LL);
                            } else l=(f[_tail]*_1e9+f[_tail-1])/(y.back()+1),r=min((f[_tail]*_1e9+f[_tail-1]+1)/y.back(),999999999LL);
                        }
                        while(l<=r) {
                            int mid=(l+r)>>1;
                            f_len=0,ct=0;
                            for(int i=0; i<(int)y.size(); ++i)ct+=y[i]*mid,g[f_len++]=ct%_1e9,ct/=_1e9;
                            while(ct)g[f_len++]=ct%_1e9,ct/=_1e9;
                            if(chu_cmp(f,_head,_tail,g,f_len))p=mid,l=mid+1;
                            else r=mid-1;
                        }
                        for(int j=_head; j<_head+(int)y.size(); ++j) {
                            f[j]-=y[j-_head]*p;
                            if(f[j]<0)f[j+1]-=(-f[j])/_1e9+((-f[j])%_1e9>0),f[j]=(f[j]+_1e18)%_1e9;
                        }
                        while(_head<=_tail&&f[_tail]==0)--_tail;
                    }
                }
                vector<long long>c;
                for(int i=_head; i<=_tail; ++i) c.push_back(f[i]);
                return c;
            }
            vector<long long> FFT(vector<long long>str1, vector<long long>str2) noexcept {
                char *a=(char*)(malloc(str1.size()*9+1)), *b=(char*)(malloc(str2.size()*9+1)), *at=a, *bt=b;
                string tmp=to_string(str1.back());
                for(auto tmpi : tmp) *(at++)=tmpi;
                for (int i = str1.size()-2; ~i; --i) {
                    long long &p=str1[i];
                    for(char* j=at+8; j>=at; --j) *j=((p%10)|48), p/=10;
                    at+=9;
                }
                tmp=to_string(str2.back());
                for(auto tmpi : tmp) *(bt++)=tmpi;
                for (int i = str2.size()-2; ~i; --i) {
                    long long &p=str2[i];
                    for(char* j=bt+8; j>=bt; --j) *j=((p%10)|48), p/=10;
                    bt+=9;
                }
                string res;
                __fft__base::main(a,at,b,bt,res);
                vector<long long>data;
                for (int i=res.size()-1; i>=0; i-=9) {
                    int st = max(0, i-8), len = i-st+1;
                    data.push_back((long long)(atoi(res.substr(st,len).c_str())));
                }
                return data;
            }
        public:
            inline friend __int114514 __fft__mul(__int114514 &x, __int114514 &y) noexcept {
                return {x.FFT(x.data,y.data),bool(x.f^y.f)};
            }
        private:

            //负数处理
            inline __int114514 fu_sub(__int114514 &x,__int114514 &y) noexcept {
                if(x.f == y.f) {
                    if(cmp(x.data,y.data)) // 判断够不够减
                        return {sub(x.data,y.data),x.f};
                    else
                        return {sub(y.data,x.data),!x.f};
                } else {
                    return {add(x.data,y.data),x.f};
                }
            }
            inline __int114514 fu_add(const __int114514 &x,const __int114514 &y) const noexcept {
                if(x.f == y.f) {
                    return {add(x.data,y.data), x.f};
                } else {
                    if(cmp(x.data,y.data)) return {sub(x.data,y.data),x.f};
                    else return {sub(y.data,x.data),y.f};
                }
            }
            inline __int114514 fu_cf(__int114514 &x,__int114514 &y) noexcept {
                // 大数自动用 NTT
                if(x.data.size()*y.data.size() > 300000) return __fft__mul(x,y);
                return {cf(x.data,y.data),bool(x.f^y.f)};
            }
            // 保留一个朴素乘法的函数,方便调试
            inline friend __int114514 __nofft__mul(__int114514 &x,__int114514 &y) noexcept {
                return {x.cf(x.data,y.data),bool(x.f^y.f)};
            }
            inline __int114514 fu_chu(__int114514 &x,__int114514 &y) noexcept {
                return {chu(x.data,y.data),bool(x.f^y.f)};
            }

            //IO
            void read() noexcept {
                data.clear();
                string s;
                cin >> s;
                if(s[0] == '-') f=1;
                else f=0;
                for (int i=s.size()-1; i>=f; i-=9) {
                    int st = max(int(f), i-8), len = i-st+1;
                    data.push_back((long long)(atoi(s.substr(st,len).c_str())));
                }
            }
            void write() const noexcept {
                if(f) putchar('-');
                printf("%lld",data.back());
                for (int i = data.size()-2; ~i; --i) printf("%09lld", data[i]);
            }
            vector<long long>data;
            bool f;

        public:
            char* to_str() const noexcept {
                char* p=(char*)malloc(data.size()*9+3), *t=p;
                if(f) *(t++)='-';
                t+=sprintf(t,"%lld",data.back());
                for (int i = data.size()-2; ~i; --i) t+=sprintf(t,"%09lld", data[i]);
                *t=0;
                return p;
            }


            template<typename T>  __int114514(T _b) noexcept {
                long long b = _b;
                if(b<0) f=1, b=-b;
                else f=0;
                if(b==0) data.push_back(0);
                while(b) {
                    data.push_back(b%_1e9);
                    b/=_1e9;
                }
            }
            __int114514(vector<long long>a, bool b) noexcept {
                data=a;
                f=b;
            }
            __int114514(vector<long long>a) noexcept {
                data=a;
                f=0;
            }
            __int114514(string s) noexcept {
                data.clear();
                if(s[0] == '-') f=1;
                else f=0;
                for (int i=s.size()-1; i>=f; i-=9) {
                    int st = max(int(f), i-8), len = i-st+1;
                    data.push_back((long long)(atoi(s.substr(st,len).c_str())));
                }
            }
            __int114514(const char* s) noexcept {
                *this = (string)s;
            }
            __int114514() noexcept {
                f=0;
                data.push_back(0);
            }

            //比较
            bool operator > (__int114514 &b) noexcept {
                int s1,s2;
                if(data.size()==1 && data[0]==0) s1 = 0;
                else s1 = f ? -1 : 1;
                if(b.data.size()==1 && b.data[0]==0) s2 = 0;
                else s2 = b.f ? -1 : 1;
                if(s1 > s2) return 1;
                if(s1 < s2) return 0;
                if(data.size() > b.data.size()) return s1==1?1:0;
                if(data.size() < b.data.size()) return s1==1?0:1;
                for(int i=data.size()-1; ~i; --i) {
                    if(data[i] > b.data[i]) return s1==1?1:0;
                    if(data[i] < b.data[i]) return s1==1?0:1;
                }
                return 0;
            }
            bool operator <= (__int114514 &b) noexcept {
                return !(*this > b);
            }
            bool operator >= (__int114514 &b) noexcept {
                int s1,s2;
                if(data.size()==1 && data[0]==0) s1 = 0;
                else s1 = f ? -1 : 1;
                if(b.data.size()==1 && b.data[0]==0) s2 = 0;
                else s2 = b.f ? -1 : 1;
                if(s1 > s2) return 1;
                if(s1 < s2) return 0;
                if(data.size() > b.data.size()) return s1==1?1:0;
                if(data.size() < b.data.size()) return s1==1?0:1;
                for(int i=data.size()-1; ~i; --i) {
                    if(data[i] > b.data[i]) return s1==1?1:0;
                    if(data[i] < b.data[i]) return s1==1?0:1;
                }
                return 1;
            }
            bool operator < (__int114514 &b) noexcept {
                return !(*this >= b);
            }
            bool operator == (__int114514 &b) noexcept {
                int s1,s2;
                if(data.size()==1 && data[0]==0) s1 = 0;
                else s1 = f ? -1 : 1;
                if(b.data.size()==1 && b.data[0]==0) s2 = 0;
                else s2 = b.f ? -1 : 1;
                if(s1 != s2 || data.size() != b.data.size()) return 0;
                for(int i=0; i<(int)data.size(); ++i)
                    if(data[i] != b.data[i]) return 0;
                return 1;
            }
            bool operator != (__int114514 &b) noexcept {
                return !(*this == b);
            }

            __int114514 & operator ++() noexcept { // 前缀++
                __int114514 a = 1;
                *this = fu_add(*this,a);
                return *this;
            }
            __int114514 operator + () noexcept { // 正号
                return *this;
            }
            __int114514 operator - () noexcept { // 负号
                return {data, !f};
            }
            __int114514 operator ++(int) noexcept { // 后缀++
                __int114514 old = *this;
                __int114514 a = 1;
                *this = fu_add(*this,a);
                return old;
            }
            __int114514 & operator --() noexcept { // 前缀--
                __int114514 a = 1;
                *this = fu_sub(*this,a);
                return *this;
            }
            __int114514 operator --(int) noexcept { // 后缀--
                __int114514 old = *this;
                __int114514 a = 1;
                *this = fu_sub(*this,a);
                return old;
            }

            //重载运算符
            __int114514 operator+(__int114514 &y) noexcept {
                return fu_add(*this,y);
            }
            __int114514 operator+(__int114514 &y) const noexcept {
                return fu_add(*this,y);
            }
            __int114514 operator-(__int114514 &y) noexcept {
                return fu_sub(*this,y);
            }
            __int114514 operator*(__int114514 &y) noexcept {
                return fu_cf(*this,y);
            }
            __int114514 operator/(__int114514 &y) noexcept {
                return fu_chu(*this,y);
            }
            __int114514 operator%(__int114514 &y) noexcept {
                return {mod(data,y.data),f};
            }
            //重载操作符
            __int114514 & operator+=(__int114514 &b) noexcept {
                *this = *this + b;
                return *this;
            }
            __int114514 & operator-=(__int114514 &b) noexcept {
                *this = *this - b;
                return *this;
            }
            __int114514 & operator*=(__int114514 &b) noexcept {
                *this = *this * b;
                return *this;
            }
            __int114514 & operator/=(__int114514 &b) noexcept {
                *this = *this / b;
                return *this;
            }
            __int114514 & operator%=(__int114514 &b) noexcept {
                *this = *this % b;
                return *this;
            }

            //重载输入输出
            friend istream & operator>>(istream &in, __int114514 &a) noexcept {
                a.read();
                return in;
            }
            friend ostream & operator<<(ostream &out, const __int114514 &a) noexcept {
                a.write();
                return out;
            }

            //高精与低精
            template<typename T>   __int114514 operator+(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this + cache);
            }
            template<typename T>   __int114514 & operator+=(T y) noexcept {
                __int114514 cache = __int114514(y);
                return *this = (*this + cache);
            }
            template<typename T>   __int114514 operator-(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this - cache);
            }
            template<typename T>   __int114514 & operator-=(T y) noexcept {
                __int114514 cache = __int114514(y);
                return *this = (*this - cache);
            }
            template<typename T>   __int114514 operator*(T y) noexcept {
                return {cheng_int(data, abs(y)), bool(f^(y<0))};
            }
            template<typename T>   __int114514 & operator*=(T y) noexcept {
                return (*this = {cheng_int(data, abs(y)), bool(f^(y<0))} );
            }
            template<typename T>   __int114514 operator/(T y) noexcept {
                return {chu_int(data,abs(y)),bool(f^(y<0))};
            }
            template<typename T>   __int114514 & operator/=(T y) noexcept {
                return (*this = {chu_int(data,abs(y)),bool(f^(y<0))} );
            }
            template<typename T>  int operator%(T y) noexcept {
                if(_1e9 % y == 0) return (data[0] % y) * (f?-1:1);
                return mod_int(data,abs(y)) * (f?-1:1);
            }
            template<typename T>   __int114514 & operator%=(T y) noexcept {
                return ( *this = *this % y );
            }
            template<typename T>   bool operator>(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this > cache);
            }
            template<typename T>   bool operator>=(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this >= cache);
            }
            template<typename T>   bool operator<(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this < cache);
            }
            template<typename T>   bool operator<=(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this <= cache);
            }
            template<typename T>   bool operator==(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this == cache);
            }
            template<typename T>   bool operator!=(T y) noexcept {
                __int114514 cache = __int114514(y);
                return (*this != cache);
            }
            //高精与低精(const)
            template<typename T>   __int114514 operator+(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this + cache);
            }
            template<typename T>   __int114514 & operator+=(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return *this = (*this + cache);
            }
            template<typename T>   __int114514 operator-(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this - cache);
            }
            template<typename T>   __int114514 & operator-=(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return *this = (*this - cache);
            }
            template<typename T>   __int114514 operator*(T y) const noexcept {
                return {cheng_int(data, abs(y)), bool(f^(y<0))};
            }
            template<typename T>   __int114514 & operator*=(T y) const noexcept {
                return (*this = {cheng_int(data, abs(y)), bool(f^(y<0))} );
            }
            template<typename T>   __int114514 operator/(T y) const noexcept {
                return {chu_int(data,abs(y)),bool(f^(y<0))};
            }
            template<typename T>   __int114514 & operator/=(T y) const noexcept {
                return (*this = {chu_int(data,abs(y)),bool(f^(y<0))} );
            }
            template<typename T>  int operator%(T y) const noexcept {
                if(_1e9 % y == 0) return (data[0] % y) * (f?-1:1);
                return mod_int(data,abs(y)) * (f?-1:1);
            }
            template<typename T>   __int114514 & operator%=(T y) const noexcept {
                return ( *this = *this % y );
            }
            template<typename T>   bool operator>(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this > cache);
            }
            template<typename T>   bool operator>=(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this >= cache);
            }
            template<typename T>   bool operator<(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this < cache);
            }
            template<typename T>   bool operator<=(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this <= cache);
            }
            template<typename T>   bool operator==(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this == cache);
            }
            template<typename T>   bool operator!=(T y) const noexcept {
                __int114514 cache = __int114514(y);
                return (*this != cache);
            }

            //其他
            friend __int114514 abs(__int114514 &x) noexcept {
                return {x.data, 0};
            }
            friend __int114514 pow(__int114514 &x, int k) noexcept {
                __int114514 ans = 1, temp = x;
                while(k) {
                    if(k&1) ans *= temp;
                    temp *= temp;
                    k >>= 1;
                }
                return ans;
            }
            friend __int114514 operator & (__int114514 &a, __int114514 &b) noexcept {

                short a_01[a.data.size()<<2], b_01[b.data.size()<<2];
                int n=0,m=0;

                vector<long long>p = a.data;
                while(p.size() > 1 || p[0]) a_01[n++]=p[0]%512, p=a.chu_int(p,512);
                p = b.data;
                while(p.size() > 1 || p[0]) b_01[m++]=p[0]%512, p=b.chu_int(p,512);

                __int114514 ans;
                for(int i=min(n,m)-1; ~i; --i) {
                    ans *= 512;
                    __int114514 temp = __int114514(a_01[i] & b_01[i]);
                    ans += temp;
                }

                return ans;
            }
            friend __int114514 operator | (__int114514 &a, __int114514 &b) noexcept {

                int len = max(a.data.size(),b.data.size())<<2;
                short a_01[len], b_01[len];
                memset(a_01,0,sizeof a_01);
                memset(b_01,0,sizeof b_01);
                int n=0,m=0;

                vector<long long>p = a.data;
                while(p.size() > 1 || p[0]) a_01[n++]=p[0]%512, p=a.chu_int(p,512);
                p = b.data;
                while(p.size() > 1 || p[0]) b_01[m++]=p[0]%512, p=b.chu_int(p,512);

                __int114514 ans;
                for(int i=max(n,m)-1; ~i; --i) {
                    ans *= 512;
                    __int114514 temp = __int114514(a_01[i] | b_01[i]);
                    ans += temp;
                }

                return ans;
            }
            __int114514 operator ~ () noexcept {
                return -(*this)-1;
            }

            void __moveR(int k) noexcept {
                for(int i=0; i<k; ++i) {
                    data.push_back(0);
                }
                for(int i=0; i<(int)data.size()-k; ++i) data[i+k]=data[i], data[i]=0;
            }
            // 强制类型转换
            operator bool() const noexcept {
                return *(const_cast<__int114514*>(this)) != 0;
            }
            operator short() const noexcept {
                return (f?-1:1)*(data[0]%32768);
            }
            operator unsigned short() const noexcept {
                return data[0];
            }
            operator int() const noexcept {
                return (f?-1:1)*data[0];
            }
            operator unsigned int() const noexcept {
                return data[0];
            }
            operator long long() const noexcept {
                if(data.size() > 1) return (f?-1:1)*data[1]*_1e9+data[0];
                else return (f?-1:1)*data[0];
            }
            operator unsigned long long() const noexcept {
                if(data.size() > 1) return data[1]*_1e9+data[0];
                else return data[0];
            }
            inline int len() const noexcept {
                return data.size();
            }
    };
}
#undef _1e9
#undef _1e18

超级屎山版(直接塞到int main前即可使用)

#include<bits/stdc++.h>
const double PI=acos(-1.0);
#define _1e9 1000000000LL
#define _1e18 1000000000000000000LL
#if __cplusplus<201103
#define noexcept throw()
#endif
namespace std{namespace __fft__base{const int N=1<<20;inline int bceil(int x){return(x==1||x==0)?x:(1<<(__lg(x-1)+1));}namespace f_f_t{const double Pi_2=acos(-1.0)/2;complex<double>w[N>>3];int init_l;inline void init(int l){if(l<=init_l)return;int t=__lg(l-1);l=1<<t,*w=complex<double>(1.0,0.0),init_l=l<<1;for(int i=1;i<l;i<<=1)w[i]=polar(1.0,Pi_2/i);for(int i=1;i<l;++i)w[i]=w[i&(i-1)]*w[i&-i];}void dif(complex<double>*f,int&L){for(int l=L>>1,r=L;l;l>>=1,r>>=1){for(complex<double>*j=f,*o=w;j!=f+L;j+=r,++o){for(complex<double>*k=j;k!=j+l;++k){complex<double>x=*k,y=k[l]**o;*k=x+y,k[l]=x-y;}}}}void dit(complex<double>*f,int&L){for(int l=1,r=2;l<L;l<<=1,r<<=1){for(complex<double>*j=f,*o=w;j!=f+L;j+=r,++o){for(complex<double>*k=j;k!=j+l;++k){complex<double>x=*k,y=k[l];*k=x+y,k[l]=(x-y)*conj(*o);}}}}void Conv(double*f,int&lim,double*g){complex<double>*F=(complex<double>*)f,*G=(complex<double>*)g;int l=lim>>1;init(l),dif(F,l),dif(G,l);double fx=2.0/lim,fx2=0.5/lim;F[0]=(F[0]*G[0]+2*F[0].imag()*G[0].imag())*fx,F[1]=F[1]*G[1]*fx;for(int k=2,m=3;k<l;k<<=1,m<<=1){for(int i=k,j=i+k-1;i<m;++i,--j){complex<double>oi=(F[i]+conj(F[j])),hi=(F[i]-conj(F[j]));complex<double>Oi=(G[i]+conj(G[j])),Hi=(G[i]-conj(G[j]));complex<double>r0=oi*Oi-hi*Hi*((i&1)?-w[i>>1]:w[i>>1]),r1=Oi*hi+oi*Hi;F[i]=(r0+r1)*fx2,F[j]=conj(r0-r1)*fx2;}}dit(F,l);}}double F[N>>1],G[N>>1];char buf[N<<1];void main(char*bga,char*eda,char*bgb,char*edb,string&ans){auto radX=[](char*bg,char*ed,double*out){char*edr=bg+4,*pos=ed;for(;pos>edr;pos-=4)*out++=*(pos-4)*1000+*(pos-3)*100+*(pos-2)*10+*(pos-1)-53328;return*out++=stod(string(bg,pos)),out;};int n=radX(bga,eda,F)-F,m=radX(bgb,edb,G)-G,lim=max(8,bceil(n+m-1));fill(F+n,F+lim,0.0),fill(G+m,G+lim,0.0),f_f_t::Conv(F,lim,G);struct ict{int num[10000];ict(){int j=0;for(int e0=(48<<0);e0<(58<<0);e0+=(1<<0))for(int e1=(48<<8);e1<(58<<8);e1+=(1<<8))for(int e2=(48<<16);e2<(58<<16);e2+=(1<<16))for(int e3=(48<<24);e3<(58<<24);e3+=(1<<24))num[j++]=e0^e1^e2^e3;}}ot;int o=(n+m-2),*ed=(int*)buf+o,*c=ed;unsigned long long u=0;for(int p=0;p<o;++p)u+=(unsigned long long)(F[p]+0.5),*--c=ot.num[u%10000u],u/=10000u;ans=to_string(u+(unsigned long long)(F[o]+0.5));for(char*p=reinterpret_cast<char*>(c);p<reinterpret_cast<char*>(ed);p++)ans+=*p;}};const double PI=acos(-1.0);class __int114514{private:inline bool cmp(const vector<long long>&a,const vector<long long>&b)const noexcept{if(a.size()>b.size())return 1;if(a.size()<b.size())return 0;for(int i=a.size()-1;~i;--i){if(a[i]>b[i])return 1;if(a[i]<b[i])return 0;}return 1;}vector<long long>chu_int(const vector<long long>&a,int b)const noexcept{long long t=0;vector<long long>c;for(int i=a.size()-1;~i;--i){t=t*_1e9+a[i];c.push_back(t/b);t%=b;}reverse(c.begin(),c.end());while(c.size()>1&&c.back()==0)c.pop_back();return c;}int mod_int(vector<long long>&a,int b)noexcept{long long t=0;vector<long long>c;for(int i=a.size()-1;~i;--i){t=t*_1e9+a[i];t%=b;}return t;}vector<long long>cheng_int(const vector<long long>&a,int b)const noexcept{long long t=0;vector<long long>c;for(int i=0;i<(int)a.size();++i){t+=a[i]*b;c.push_back(t%_1e9);t/=_1e9;}while(t){c.push_back(t%_1e9);t/=_1e9;}return c;}vector<long long>add(const vector<long long>&a,const vector<long long>&b)const noexcept{vector<long long>c;for(long long i=0,t=0;i<(int)a.size()||i<(int)b.size()||t;++i){if(i<(int)a.size())t+=a[i];if(i<(int)b.size())t+=b[i];c.push_back(t%_1e9);t/=_1e9;}return c;}vector<long long>sub(const vector<long long>&a,const vector<long long>&b)const noexcept{vector<long long>c;long long t=0;for(int i=0;i<(int)a.size();++i){t+=a[i];if(i<(int)b.size())t-=b[i];c.push_back((t+_1e9)%_1e9);if(t<0)t=-1;else t=0;}while(c.size()>1&&c.back()==0)c.pop_back();return c;}vector<long long>cf(const vector<long long>&a,const vector<long long>&b)const noexcept{vector<long long>c(a.size()+b.size()+1);for(int i=0;i<(int)a.size();++i){for(int j=0;j<(int)b.size();++j){int k=i+j;c[k]+=a[i]*b[j],c[k+1]+=c[k]/_1e9,c[k]%=_1e9;}}while(c.size()>1&&!c.back())c.pop_back();return c;}inline bool chu_cmp(const long long*a,const int&a_h,const int&a_t,const int*b,const int&bsize)const noexcept{if(a_t-a_h+1>bsize)return 1;if(a_t-a_h+1<bsize)return 0;for(int i=bsize-1;~i;--i){if(a[a_h+i]>b[i])return 1;if(a[a_h+i]<b[i])return 0;}return 1;}vector<long long>chu(const vector<long long>&x,const vector<long long>&y)const noexcept{vector<long long>c;long long f[x.size()+5];int _head=x.size()+2,_tail=x.size()+1;int g[y.size()+5];int f_len;long long ct;if(x.size()<y.size()){c.push_back(0);return c;}for(int i=x.size()-1;~i;--i){f[--_head]=x[i];if(_tail-_head+1>=(int)y.size()){int l,r,p=0;if(_tail-_head+1==y.size())l=f[_tail]/(y.back()+1),r=(f[_tail]+1)/y.back();else{if(y.size()>=3){__int128 ff=(__int128(f[_tail]*_1e9+f[_tail-1])*_1e9+f[_tail-2])*_1e9+f[_tail-3];__int128 gg=(__int128(y.back()*_1e9+y[y.size()-2])*_1e9+y[y.size()-3]);l=ff/(gg+1),r=min((long long)((ff+1)/gg),999999999LL);}else l=(f[_tail]*_1e9+f[_tail-1])/(y.back()+1),r=min((f[_tail]*_1e9+f[_tail-1]+1)/y.back(),999999999LL);}while(l<=r){int mid=(l+r)>>1;f_len=0,ct=0;for(int i=0;i<(int)y.size();++i)ct+=y[i]*mid,g[f_len++]=ct%_1e9,ct/=_1e9;while(ct)g[f_len++]=ct%_1e9,ct/=_1e9;if(chu_cmp(f,_head,_tail,g,f_len))p=mid,l=mid+1;else r=mid-1;}for(int j=_head;j<_head+(int)y.size();++j){f[j]-=y[j-_head]*p;if(f[j]<0)f[j+1]-=(-f[j])/_1e9+((-f[j])%_1e9>0),f[j]=(f[j]+_1e18)%_1e9;}c.push_back(p);while(_head<=_tail&&f[_tail]==0)--_tail;}else c.push_back(0);}reverse(c.begin(),c.end());while(c.size()>1&&c.back()==0)c.pop_back();return c;}vector<long long>mod(vector<long long>&x,vector<long long>&y)noexcept{long long f[x.size()+5];int _head=x.size()+2,_tail=x.size()+1;int g[y.size()+5];int f_len;long long ct;if(x.size()<y.size())return x;for(int i=x.size()-1;~i;--i){f[--_head]=x[i];if(_tail-_head+1>=(int)y.size()){int l,r,p=0;if(_tail-_head+1==y.size())l=f[_tail]/(y.back()+1),r=(f[_tail]+1)/y.back();else{if(y.size()>=3){__int128 ff=(__int128(f[_tail]*_1e9+f[_tail-1])*_1e9+f[_tail-2])*_1e9+f[_tail-3];__int128 gg=(__int128(y.back()*_1e9+y[y.size()-2])*_1e9+y[y.size()-3]);l=ff/(gg+1),r=min((long long)((ff+1)/gg),999999999LL);}else l=(f[_tail]*_1e9+f[_tail-1])/(y.back()+1),r=min((f[_tail]*_1e9+f[_tail-1]+1)/y.back(),999999999LL);}while(l<=r){int mid=(l+r)>>1;f_len=0,ct=0;for(int i=0;i<(int)y.size();++i)ct+=y[i]*mid,g[f_len++]=ct%_1e9,ct/=_1e9;while(ct)g[f_len++]=ct%_1e9,ct/=_1e9;if(chu_cmp(f,_head,_tail,g,f_len))p=mid,l=mid+1;else r=mid-1;}for(int j=_head;j<_head+(int)y.size();++j){f[j]-=y[j-_head]*p;if(f[j]<0)f[j+1]-=(-f[j])/_1e9+((-f[j])%_1e9>0),f[j]=(f[j]+_1e18)%_1e9;}while(_head<=_tail&&f[_tail]==0)--_tail;}}vector<long long>c;for(int i=_head;i<=_tail;++i)c.push_back(f[i]);return c;}vector<long long>FFT(vector<long long>str1,vector<long long>str2)noexcept{char*a=(char*)(malloc(str1.size()*9+1)),*b=(char*)(malloc(str2.size()*9+1)),*at=a,*bt=b;string tmp=to_string(str1.back());for(auto tmpi:tmp)*(at++)=tmpi;for(int i=str1.size()-2;~i;--i){long long&p=str1[i];for(char*j=at+8;j>=at;--j)*j=((p%10)|48),p/=10;at+=9;}tmp=to_string(str2.back());for(auto tmpi:tmp)*(bt++)=tmpi;for(int i=str2.size()-2;~i;--i){long long&p=str2[i];for(char*j=bt+8;j>=bt;--j)*j=((p%10)|48),p/=10;bt+=9;}string res;__fft__base::main(a,at,b,bt,res);vector<long long>data;for(int i=res.size()-1;i>=0;i-=9){int st=max(0,i-8),len=i-st+1;data.push_back((long long)(atoi(res.substr(st,len).c_str())));}return data;}public:inline friend __int114514 __fft__mul(__int114514&x,__int114514&y)noexcept{return{x.FFT(x.data,y.data),bool(x.f^y.f)};}private:inline __int114514 fu_sub(__int114514&x,__int114514&y)noexcept{if(x.f==y.f){if(cmp(x.data,y.data))return{sub(x.data,y.data),x.f};else return{sub(y.data,x.data),!x.f};}else{return{add(x.data,y.data),x.f};}}inline __int114514 fu_add(const __int114514&x,const __int114514&y)const noexcept{if(x.f==y.f){return{add(x.data,y.data),x.f};}else{if(cmp(x.data,y.data))return{sub(x.data,y.data),x.f};else return{sub(y.data,x.data),y.f};}}inline __int114514 fu_cf(__int114514&x,__int114514&y)noexcept{if(x.data.size()*y.data.size()>300000)return __fft__mul(x,y);return{cf(x.data,y.data),bool(x.f^y.f)};}inline friend __int114514 __nofft__mul(__int114514&x,__int114514&y)noexcept{return{x.cf(x.data,y.data),bool(x.f^y.f)};}inline __int114514 fu_chu(__int114514&x,__int114514&y)noexcept{return{chu(x.data,y.data),bool(x.f^y.f)};}void read()noexcept{data.clear();string s;cin>>s;if(s[0]=='-')f=1;else f=0;for(int i=s.size()-1;i>=f;i-=9){int st=max(int(f),i-8),len=i-st+1;data.push_back((long long)(atoi(s.substr(st,len).c_str())));}}void write()const noexcept{if(f)putchar('-');printf("%lld",data.back());for(int i=data.size()-2;~i;--i)printf("%09lld",data[i]);}vector<long long>data;bool f;public:char*to_str()const noexcept{char*p=(char*)malloc(data.size()*9+3),*t=p;if(f)*(t++)='-';t+=sprintf(t,"%lld",data.back());for(int i=data.size()-2;~i;--i)t+=sprintf(t,"%09lld",data[i]);*t=0;return p;}template<typename T>__int114514(T _b)noexcept{long long b=_b;if(b<0)f=1,b=-b;else f=0;if(b==0)data.push_back(0);while(b){data.push_back(b%_1e9);b/=_1e9;}}__int114514(vector<long long>a,bool b)noexcept{data=a;f=b;}__int114514(vector<long long>a)noexcept{data=a;f=0;}__int114514(string s)noexcept{data.clear();if(s[0]=='-')f=1;else f=0;for(int i=s.size()-1;i>=f;i-=9){int st=max(int(f),i-8),len=i-st+1;data.push_back((long long)(atoi(s.substr(st,len).c_str())));}}__int114514(const char*s)noexcept{*this=(string)s;}__int114514()noexcept{f=0;data.push_back(0);}bool operator>(__int114514&b)noexcept{int s1,s2;if(data.size()==1&&data[0]==0)s1=0;else s1=f?-1:1;if(b.data.size()==1&&b.data[0]==0)s2=0;else s2=b.f?-1:1;if(s1>s2)return 1;if(s1<s2)return 0;if(data.size()>b.data.size())return s1==1?1:0;if(data.size()<b.data.size())return s1==1?0:1;for(int i=data.size()-1;~i;--i){if(data[i]>b.data[i])return s1==1?1:0;if(data[i]<b.data[i])return s1==1?0:1;}return 0;}bool operator<=(__int114514&b)noexcept{return!(*this>b);}bool operator>=(__int114514&b)noexcept{int s1,s2;if(data.size()==1&&data[0]==0)s1=0;else s1=f?-1:1;if(b.data.size()==1&&b.data[0]==0)s2=0;else s2=b.f?-1:1;if(s1>s2)return 1;if(s1<s2)return 0;if(data.size()>b.data.size())return s1==1?1:0;if(data.size()<b.data.size())return s1==1?0:1;for(int i=data.size()-1;~i;--i){if(data[i]>b.data[i])return s1==1?1:0;if(data[i]<b.data[i])return s1==1?0:1;}return 1;}bool operator<(__int114514&b)noexcept{return!(*this>=b);}bool operator==(__int114514&b)noexcept{int s1,s2;if(data.size()==1&&data[0]==0)s1=0;else s1=f?-1:1;if(b.data.size()==1&&b.data[0]==0)s2=0;else s2=b.f?-1:1;if(s1!=s2||data.size()!=b.data.size())return 0;for(int i=0;i<(int)data.size();++i)if(data[i]!=b.data[i])return 0;return 1;}bool operator!=(__int114514&b)noexcept{return!(*this==b);}__int114514&operator++()noexcept{__int114514 a=1;*this=fu_add(*this,a);return*this;}__int114514 operator+()noexcept{return*this;}__int114514 operator-()noexcept{return{data,!f};}__int114514 operator++(int)noexcept{__int114514 old=*this;__int114514 a=1;*this=fu_add(*this,a);return old;}__int114514&operator--()noexcept{__int114514 a=1;*this=fu_sub(*this,a);return*this;}__int114514 operator--(int)noexcept{__int114514 old=*this;__int114514 a=1;*this=fu_sub(*this,a);return old;}__int114514 operator+(__int114514&y)noexcept{return fu_add(*this,y);}__int114514 operator+(__int114514&y)const noexcept{return fu_add(*this,y);}__int114514 operator-(__int114514&y)noexcept{return fu_sub(*this,y);}__int114514 operator*(__int114514&y)noexcept{return fu_cf(*this,y);}__int114514 operator/(__int114514&y)noexcept{return fu_chu(*this,y);}__int114514 operator%(__int114514&y)noexcept{return{mod(data,y.data),f};}__int114514&operator+=(__int114514&b)noexcept{*this=*this+b;return*this;}__int114514&operator-=(__int114514&b)noexcept{*this=*this-b;return*this;}__int114514&operator*=(__int114514&b)noexcept{*this=*this*b;return*this;}__int114514&operator/=(__int114514&b)noexcept{*this=*this/b;return*this;}__int114514&operator%=(__int114514&b)noexcept{*this=*this%b;return*this;}friend istream&operator>>(istream&in,__int114514&a)noexcept{a.read();return in;}friend ostream&operator<<(ostream&out,const __int114514&a)noexcept{a.write();return out;}template<typename T>__int114514 operator+(T y)noexcept{__int114514 cache=__int114514(y);return(*this+cache);}template<typename T>__int114514&operator+=(T y)noexcept{__int114514 cache=__int114514(y);return*this=(*this+cache);}template<typename T>__int114514 operator-(T y)noexcept{__int114514 cache=__int114514(y);return(*this-cache);}template<typename T>__int114514&operator-=(T y)noexcept{__int114514 cache=__int114514(y);return*this=(*this-cache);}template<typename T>__int114514 operator*(T y)noexcept{return{cheng_int(data,abs(y)),bool(f^(y<0))};}template<typename T>__int114514&operator*=(T y)noexcept{return(*this={cheng_int(data,abs(y)),bool(f^(y<0))});}template<typename T>__int114514 operator/(T y)noexcept{return{chu_int(data,abs(y)),bool(f^(y<0))};}template<typename T>__int114514&operator/=(T y)noexcept{return(*this={chu_int(data,abs(y)),bool(f^(y<0))});}template<typename T>int operator%(T y)noexcept{if(_1e9%y==0)return(data[0]%y)*(f?-1:1);return mod_int(data,abs(y))*(f?-1:1);}template<typename T>__int114514&operator%=(T y)noexcept{return(*this=*this%y);}template<typename T>bool operator>(T y)noexcept{__int114514 cache=__int114514(y);return(*this>cache);}template<typename T>bool operator>=(T y)noexcept{__int114514 cache=__int114514(y);return(*this>=cache);}template<typename T>bool operator<(T y)noexcept{__int114514 cache=__int114514(y);return(*this<cache);}template<typename T>bool operator<=(T y)noexcept{__int114514 cache=__int114514(y);return(*this<=cache);}template<typename T>bool operator==(T y)noexcept{__int114514 cache=__int114514(y);return(*this==cache);}template<typename T>bool operator!=(T y)noexcept{__int114514 cache=__int114514(y);return(*this!=cache);}template<typename T>__int114514 operator+(T y)const noexcept{__int114514 cache=__int114514(y);return(*this+cache);}template<typename T>__int114514&operator+=(T y)const noexcept{__int114514 cache=__int114514(y);return*this=(*this+cache);}template<typename T>__int114514 operator-(T y)const noexcept{__int114514 cache=__int114514(y);return(*this-cache);}template<typename T>__int114514&operator-=(T y)const noexcept{__int114514 cache=__int114514(y);return*this=(*this-cache);}template<typename T>__int114514 operator*(T y)const noexcept{return{cheng_int(data,abs(y)),bool(f^(y<0))};}template<typename T>__int114514&operator*=(T y)const noexcept{return(*this={cheng_int(data,abs(y)),bool(f^(y<0))});}template<typename T>__int114514 operator/(T y)const noexcept{return{chu_int(data,abs(y)),bool(f^(y<0))};}template<typename T>__int114514&operator/=(T y)const noexcept{return(*this={chu_int(data,abs(y)),bool(f^(y<0))});}template<typename T>int operator%(T y)const noexcept{if(_1e9%y==0)return(data[0]%y)*(f?-1:1);return mod_int(data,abs(y))*(f?-1:1);}template<typename T>__int114514&operator%=(T y)const noexcept{return(*this=*this%y);}template<typename T>bool operator>(T y)const noexcept{__int114514 cache=__int114514(y);return(*this>cache);}template<typename T>bool operator>=(T y)const noexcept{__int114514 cache=__int114514(y);return(*this>=cache);}template<typename T>bool operator<(T y)const noexcept{__int114514 cache=__int114514(y);return(*this<cache);}template<typename T>bool operator<=(T y)const noexcept{__int114514 cache=__int114514(y);return(*this<=cache);}template<typename T>bool operator==(T y)const noexcept{__int114514 cache=__int114514(y);return(*this==cache);}template<typename T>bool operator!=(T y)const noexcept{__int114514 cache=__int114514(y);return(*this!=cache);}friend __int114514 abs(__int114514&x)noexcept{return{x.data,0};}friend __int114514 pow(__int114514&x,int k)noexcept{__int114514 ans=1,temp=x;while(k){if(k&1)ans*=temp;temp*=temp;k>>=1;}return ans;}friend __int114514 operator&(__int114514&a,__int114514&b)noexcept{short a_01[a.data.size()<<2],b_01[b.data.size()<<2];int n=0,m=0;vector<long long>p=a.data;while(p.size()>1||p[0])a_01[n++]=p[0]%512,p=a.chu_int(p,512);p=b.data;while(p.size()>1||p[0])b_01[m++]=p[0]%512,p=b.chu_int(p,512);__int114514 ans;for(int i=min(n,m)-1;~i;--i){ans*=512;__int114514 temp=__int114514(a_01[i]&b_01[i]);ans+=temp;}return ans;}friend __int114514 operator|(__int114514&a,__int114514&b)noexcept{int len=max(a.data.size(),b.data.size())<<2;short a_01[len],b_01[len];memset(a_01,0,sizeof a_01);memset(b_01,0,sizeof b_01);int n=0,m=0;vector<long long>p=a.data;while(p.size()>1||p[0])a_01[n++]=p[0]%512,p=a.chu_int(p,512);p=b.data;while(p.size()>1||p[0])b_01[m++]=p[0]%512,p=b.chu_int(p,512);__int114514 ans;for(int i=max(n,m)-1;~i;--i){ans*=512;__int114514 temp=__int114514(a_01[i]|b_01[i]);ans+=temp;}return ans;}__int114514 operator~()noexcept{return-(*this)-1;}void __moveR(int k)noexcept{for(int i=0;i<k;++i){data.push_back(0);}for(int i=0;i<(int)data.size()-k;++i)data[i+k]=data[i],data[i]=0;}operator bool()const noexcept{return*(const_cast<__int114514*>(this))!=0;}operator short()const noexcept{return(f?-1:1)*(data[0]%32768);}operator unsigned short()const noexcept{return data[0];}operator int()const noexcept{return(f?-1:1)*data[0];}operator unsigned int()const noexcept{return data[0];}operator long long()const noexcept{if(data.size()>1)return(f?-1:1)*data[1]*_1e9+data[0];else return(f?-1:1)*data[0];}operator unsigned long long()const noexcept{if(data.size()>1)return data[1]*_1e9+data[0];else return data[0];}inline int len()const noexcept{return data.size();}};}
#undef _1e9
#undef _1e18