首页 > 其他分享 >一些板子

一些板子

时间:2022-10-22 21:55:20浏览次数:45  
标签:false int Big 板子 return -- 一些 true

#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;
}

标签:false,int,Big,板子,return,--,一些,true
From: https://www.cnblogs.com/hxqasd/p/16817418.html

相关文章

  • Kaliの一些网络操作
    KAlIの一些网络操作arping-c192.168.10.1缺点是只能对单一ip进行探测,可利用shell脚本进行网段探测扫描netdiscover-ieth0-r192.168.10.0/24主动方式netd......
  • 一些重要实用指令的记录
    9.1运行级别基本介绍运行级别说明:0:关机1:单用户【类似安全模式,这个模式可以帮助找回root密码】2:多用户状态没有网络服务3:多用户状态有网络服务【使用最多】4:系统......
  • postman一些你不常用的实用技巧,竟然还能这么玩
    序言各位好啊,我是会编程的蜗牛,作为java开发者,平时调试接口的时候,肯定需要用到接口调试工具,或者Swagger之类的。Swagger的优势在于它可以将后台加的一些接口注释信息直接展......
  • Figma的一些常见问题
    查看设计稿占用的文件大小和图层总数量在视图`View`中勾选资源占用`ResourceUse`就开启了。投影扩散问题figma右下角添加投影时,里面有个Spread属性,会发现有时是禁用状态,原......
  • SEO和SEM的区别是什么,哪个效果更好一些
    SEO指的是搜索引擎优化,SEM指的是搜索引擎影响,那么SEO和SEM的区别具体是什么?对于初创业的企业来说,哪个更好呢?下面,本文将介绍SEO和SEM的区别,帮助企业和公司网络人员理清这两者......
  • 人到中年,一些想说的话
    1.永远不要放弃自己,即使自己成为不了最耀眼的那颗星,也要鼓足勇气活下去。因为上帝会淘汰不好的基因,如果你放弃了自己,上帝就会认为你是不好的基因,就会让你毁灭掉,让你得绝症......
  • dremio 社区模块的一些说明
    我以前简单说明过dremio依赖的一些社区版的包(木有开源的)以下做一个简单的总结说明社区版模式的开发模式基于独立包进行扩展扩展使用了配置动态加载或者直接引用模式,比......
  • Git极简教程(1)--总纲 ,commit(一次提交 ),一串不分叉的 commit 叫做一个 branch (图上的
    Git极简教程(1)--总纲,commit(一次提交),一串不分叉的commit叫做一个branch(图上的一根线,一条分支),一些branch聚在一起叫做一个remote(图上的一个框多个分支)最近大......
  • 论人类下一代语言的可能—5.2逻辑与自然语言的一些比较
    逻辑是一门语言吗?从莱布尼茨的通用语言,到弗雷格的概念文字,很多的逻辑学家对逻辑的看法首先是想让逻辑成为一门语言,在认知应用的方向,可以替代自然语言。较近的努力包括了德......
  • 关于post请求和get请求的一些常见问题
    1.post请求中和get请求中的请求参数都分别存在哪里?答:post方式的请求参数都存在它的实体内容中,get方式的请求参数存在于其url的后面2.post请求比get请求更安全吗?为什么?答......