一些板子

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=2e5+10;
int n;
struct Graph{
    int head[N],tot,vis[N],stk[N],dfn[N],low[N],bl[N],cnt,top,ntime;
    struct Edge{int to,nest;}bian[N<<1];
    void add(int x,int y){bian[++tot]=(Edge){y,head[x]},head[x]=tot;}
    void tarjan(int x){
        dfn[x]=low[x]=++ntime;
        vis[x]=1,stk[++top]=x;
        for(int i=head[x];i;i=bian[i].nest){
            int v=bian[i].to;
            if(!dfn[v]){
                tarjan(v);
                low[x]=min(low[x],low[v]);
            }
            else if(vis[v])low[x]=min(low[x],dfn[v]);
        }
        if(dfn[x]==low[x]){
            cnt++;
            do{
                vis[stk[top]]=0;
                bl[stk[top]]=cnt;
            }while(x!=stk[top--]);
        }
    }
}G;
namespace Tree_Cut{
    int dfn[N],dep[N],fa[N],siz[N],top[N],ntime,son[N];
    void get_heavy_son(int x,int f,int depth){
        dep[x]=depth,fa[x]=f,siz[x]=1,son[x]=0;
        for(int i=G.head[x];i;i=G.bian[i].nest){
            int v=G.bian[i].to;
            if(v==f)continue;
            get_heavy_son(v,x,depth+1);
            siz[x]+=siz[v];
            if(siz[v]>siz[son[x]])son[x]=v;
        }
    }
    void get_heavy_edge(int x,int tp){
        top[x]=tp,dfn[x]=++ntime;
        if(son[x])get_heavy_edge(son[x],tp);
        for(int i=G.head[x];i;i=G.bian[i].nest){
            int v=G.bian[i].to;
            if(v==fa[x]||v==son[x])continue;
            get_heavy_edge(v,v);
        }
    }
}
namespace SEGMENT_TREE{
    struct Segment_Tree{
        #define lson (rt << 1)
        #define rson (rt << 1 | 1)
        struct Seg{long long sum,lazy;}tree[N<<2];
        void pushup(int rt){
            tree[rt].sum=tree[lson].sum+tree[rson].sum;
        }
        void add(int rt,long long val){
            tree[rt].sum+=val;
            tree[rt].lazy+=val;
        }
        void pushdown(int rt){
            if(tree[rt].lazy){
                add(lson,tree[rt].lazy);
                add(rson,tree[rt].lazy);
                tree[rt].lazy=0;
            }
        }
        void update(int rt,int l,int r,int L,int R,long long val){
            if(l<=L&&R<=r){
                add(rt,val);
                return ;
            }
            int mid=(L+R)>>1;
            pushdown(rt);
            if(l<=mid)update(lson,l,r,L,mid,val);
            if(r>mid)update(rson,l,r,mid+1,R,val);
            pushup(rt);
        }
        long long ask(int rt,int l,int r,int L,int R){
            if(l<=L&&R<=r)return tree[rt].sum;
            int mid=(L+R)>>1;
            pushdown(rt);
            long long ans=0;
            if(l<=mid)ans+=ask(lson,l,r,L,mid);
            if(r>mid)ans+=ask(rson,l,r,mid+1,R);
            return ans;
        }
    }T;
}
namespace BIT{
    long long c[N];
    int lowbit(int x){return x&(-x);}
    void add(int x,long long val){
        while(x<=n){
            c[x]+=val;
            x+=lowbit(x);
        }
    }
    long long getsum(int x){
        long long ans=0;
        while(x){
            ans+=c[x];
            x-=lowbit(x);
        }
        return ans;
    }
}
namespace BIG_INT{
    static unsigned long long W=1000000000;
    struct Big_int{
        Big_int abs(const Big_int& a);
        Big_int read();
        void write(const Big_int& a);
        friend Big_int operator +(Big_int a,Big_int b);
        friend Big_int operator -(Big_int a,Big_int b);
        unsigned long long c[500];
        bool f;
        Big_int(){memset(c,0,sizeof(c)),f=0;}
        inline void clear(){memset(c,0,sizeof(c)),f=0;}
        inline Big_int operator =(const int& x){
            int tmp=x;
            if(x<0)f=1,tmp=-tmp;
            Big_int a;
            a.c[0]=2;
            a.c[2]=tmp/W;
            tmp%=W;
            a.c[1]=tmp;
            while(a.c[0]&&a.c[a.c[0]]==0)a.c[0]--;
            return a;
        }
        inline Big_int operator =(const unsigned int& x){
            unsigned int tmp=x;
            Big_int a;
            a.c[0]=2;
            a.c[2]=tmp/W;
            tmp%=W;
            a.c[1]=tmp;
            while(a.c[0]&&a.c[a.c[0]]==0)a.c[0]--;
            return a;
        }
        inline Big_int operator =(const long long& x){
            long long tmp=x;
            if(x<0)f=1,tmp=-tmp;
            Big_int a;
            a.c[0]=3;
            a.c[3]=tmp/(W*W);
            tmp%=W*W;
            a.c[2]=tmp/W;
            tmp%=W;
            a.c[1]=tmp;
            while(a.c[0]&&a.c[a.c[0]]==0)a.c[0]--;
            return a;
        } 
        inline Big_int operator =(const unsigned long long& x){
            unsigned long long tmp=x;
            Big_int a;
            a.c[0]=3;
            a.c[3]=tmp/(W*W);
            tmp%=W*W;
            a.c[2]=tmp/W;
            tmp%=W;
            a.c[1]=tmp;
            while(a.c[0]&&a.c[a.c[0]]==0)a.c[0]--;
            return a;
        } 
        inline friend bool operator <(Big_int a,Big_int b){
            if(a.f==1&&b.f==0)return true;
            if(a.f==0&&b.f==1)return false;
            if(a.f==0){
                if(a.c[0]>b.c[0])return false;
                if(a.c[0]<b.c[0])return true;
                for(int i=a.c[0];i>=1;i--){
                    if(a.c[i]<b.c[i])return true;
                    if(a.c[i]>b.c[i])return false;
                }
                return false;
            }
            if(a.c[0]>b.c[0])return true;
            if(a.c[0]<b.c[0])return false;
            for(int i=a.c[0];i>=1;i--){
                if(a.c[i]<b.c[i])return false;
                if(a.c[i]>b.c[i])return true;
            }
            return false;
        }
        inline friend bool operator >(Big_int a,Big_int b){
            if(a.f==1&&b.f==0)return false;
            if(a.f==0&&b.f==1)return true;
            if(a.f==0){
                if(a.c[0]>b.c[0])return true;
                if(a.c[0]<b.c[0])return false;
                for(int i=a.c[0];i>=1;i--){
                    if(a.c[i]<b.c[i])return false;
                    if(a.c[i]>b.c[i])return true;
                }
                return false;
            }
            if(a.c[0]>b.c[0])return false;
            if(a.c[0]<b.c[0])return true;
            for(int i=a.c[0];i>=1;i--){
                if(a.c[i]<b.c[i])return true;
                if(a.c[i]>b.c[i])return false;
            }
            return false;
        }
        inline friend bool operator <=(Big_int a,Big_int b){
            if(a.f==1&&b.f==0)return true;
            if(a.f==0&&b.f==1)return false;
            if(a.f==0){
                if(a.c[0]>b.c[0])return false;
                if(a.c[0]<b.c[0])return true;
                for(int i=a.c[0];i>=1;i--){
                    if(a.c[i]<b.c[i])return true;
                    if(a.c[i]>b.c[i])return false;
                }
                return true;
            }
            if(a.c[0]>b.c[0])return true;
            if(a.c[0]<b.c[0])return false;
            for(int i=a.c[0];i>=1;i--){
                if(a.c[i]<b.c[i])return false;
                if(a.c[i]>b.c[i])return true;
            }
            return true;
        }
        inline friend bool operator >=(Big_int a,Big_int b){
            if(a.f==1&&b.f==0)return false;
            if(a.f==0&&b.f==1)return true;
            if(a.f==0){
                if(a.c[0]>b.c[0])return true;
                if(a.c[0]<b.c[0])return false;
                for(int i=a.c[0];i>=1;i--){
                    if(a.c[i]<b.c[i])return false;
                    if(a.c[i]>b.c[i])return true;
                }
                return true;
            }
            if(a.c[0]>b.c[0])return false;
            if(a.c[0]<b.c[0])return true;
            for(int i=a.c[0];i>=1;i--){
                if(a.c[i]<b.c[i])return true;
                if(a.c[i]>b.c[i])return false;
            }
            return true;
        }
        inline friend bool operator ==(Big_int a,Big_int b){
            if(a.c[0]!=b.c[0])return false;
            if(a.f!=b.f)return false;
            for(int i=a.c[0];i>=1;i--){
                if(a.c[i]!=b.c[i])return false;
            }
            return true;
        }
        inline friend Big_int operator +(Big_int a,Big_int b){
            Big_int x;
            if(a.f==b.f){
                x.f=a.f;
                x.c[0]=max(a.c[0],b.c[0])+1;
                for(int i=1;i<=x.c[0];i++){
                    x.c[i]+=a.c[i]+b.c[i];
                    if(x.c[i]>=W){
                        x.c[i]-=W;
                        x.c[i+1]+=W;
                    }
                }
                while(x.c[0]&&x.c[x.c[0]]==0)x.c[0]--;
            }
            else{
                if(a.f==1)swap(a,b);
                b.f=0;
                x=a-b;
            }
            while(x.c[0]&&x.c[x.c[0]]==0)x.c[0]--;
            return x;
        }
        inline friend Big_int operator -(Big_int a,Big_int b){
            Big_int x;
            if(a.f!=b.f){
                if(a.f==1){
                    a.f=0;
                    x=a+b;
                    x.f=1;
                }
                else {
                    b.f=0;
                    x=a+b;
                }
            }
            else{
                if(a==b){
                    x.c[0]=1;
                    return x;
                }
                if(a.f==0){
                    if(a<b)x.f=1,swap(a,b);
                    int jw=0;
                    x.c[0]=a.c[0];
                    for(int i=1;i<=a.c[0];i++){
                        if(a.c[i]<b.c[i]+jw){
                            x.c[i]=W+a.c[i]-b.c[i]-jw;
                            jw=1;
                        }
                        else{
                            jw=0;
                            x.c[i]=a.c[i]-b.c[i]-jw;
                        }
                    }
                }
                else{
                    if(a>b)swap(a,b),x.f=0;
                    else x.f=1;
                    x.c[0]=a.c[0];
                    int jw=0;
                    for(int i=1;i<=a.c[0];i++){
                        if(a.c[i]<b.c[i]+jw){
                            x.c[i]=W+a.c[i]-b.c[i]-jw;
                            jw=1;
                        }
                        else{
                            x.c[i]=a.c[i]-b.c[i]-jw;
                            jw=0;
                        }
                    }
                }
            }
            while(x.c[0]&&x.c[x.c[0]]==0)x.c[0]--;
            return x;
        }
        inline friend Big_int operator *(Big_int a,Big_int b){
            Big_int x;
            if(a.f!=b.f)x.f=1;
            x.c[0]=a.c[0]+b.c[0];
            for(int i=1;i<=a.c[0];i++){
                for(int j=1;j<=b.c[0];j++){
                    x.c[i+j-1]+=a.c[i]*b.c[j];
                    if(x.c[i+j-1]>=W){
                        int now=i+j;
                        x.c[i+j]+=x.c[i+j-1]/W;
                        x.c[i+j-1]%=W;
                        while(x.c[now]>=W){
                            x.c[now+1]+=x.c[now]/W;
                            x.c[now]%=W;
                            now++;
                        }
                    }
                }
            }
            while(x.c[0]&&x.c[x.c[0]]==0)x.c[0]--;
            return x;
        }
        inline friend Big_int operator *(Big_int a,long long b){
            Big_int x;
            if(b<0)b=-b,x.f=a.f^1;
            x.c[0]=a.c[0]+1;
            for(int i=1;i<=a.c[0];i++){
                x.c[i]+=a.c[i]*1llu*b;
                if(x.c[i]>=W){
                    x.c[i+1]+=x.c[i]/W;
                    x.c[i]%=W;
                }
            }
            while(x.c[0]&&x.c[x.c[0]]==0)x.c[0]--;
            return x;
        } 
    };
    inline Big_int read(){
        Big_int a;
        char ch;
        a.c[0]=1;
        while(!isdigit(ch=getchar()))if(ch=='-')a.f=1;
        do{
            a.c[1]=(a.c[1]<<1)+(a.c[1]<<3)+(ch^48);
            int lim=a.c[0]+1;
            for(int i=2;i<=lim;i++){
                a.c[i]=(a.c[i]<<1)+(a.c[i]<<3)+(a.c[i-1]/W);
                a.c[i-1]%=W;
            }
            a.c[0]=lim;
            while(a.c[0]&&a.c[a.c[0]]==0)a.c[0]--;
        }while(isdigit(ch=getchar()));
        while(a.c[0]&&a.c[a.c[0]]==0)a.c[0]--;
        return a;
    }
    inline void write(const Big_int& a,char c){
        if(a.f)putchar('-');
        printf("%llu",a.c[a.c[0]]);
        for(int i=a.c[0]-1;i>=1;i--)printf("%09llu",a.c[i]);
        putchar(c);
    }
    inline Big_int abs(const Big_int& a){
        Big_int x;
        x=a;
        x.f=0;
        return x;
    }
    inline void swap(Big_int& a,Big_int& b){
        Big_int c;
        c=a,a.clear();
        a=b,b.clear();
        b=c;
    }
}
using namespace BIG_INT;
int main(){
    Big_int a;
    a=read();
    long long c=0;
    scanf("%lld",&c);
    write(a*c,' ');























    return 0;
}
posted @ 2022-10-22 21:49  hxqasd  阅读(49)  评论(4编辑  收藏  举报