• [else] operator


    存一波重载运算符

    只包含加,减,乘,还有快速幂。。

    压位代码:

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #define ll long long
    #define maxn 10000
    struct overload{
        ll a[5000];
        overload(){memset(a,0,sizeof a);}
        overload(int A){
            memset(a,0,sizeof(a));
            int tot=1;
            while(A){
                a[tot++]=A%maxn;
                A/=maxn;
            }
        }
        friend inline void read(overload&b){
            ll stack[10001],top=0,tot=1,t=0;
            char c=getchar();
    //        if(c<=47||c>=58){
    //            d=c;
    //            return;
    //        }
            while(c>='0'&&c<='9'){
                stack[top++]=c-48;
                c=getchar();
            }
            top--;
            while(top!=-1){
                if(top-8>=0){
                    int base=top-8;
                    while(t!=9&&top){
                        b.a[tot]=b.a[tot]*10+stack[base];
                        t++;
                        base++;
                    }
                    top-=9;
                }
                else{
                    int i=0;
                    while(i!=(top+1)){
                        b.a[tot]=b.a[tot]*10+stack[i];
                        i++;
                    }
                    top=-1;
                }
                //printf("%lld
    ",b.a[tot]);
                tot++;
                t=0;
            }
        }
        friend inline void print(const overload&b){
            bool flag=false;
            for(int tot=4000;tot>0;tot--){
                if(flag) printf("%04lld",b.a[tot]);
                else {
                if(b.a[tot]) flag=true,printf("%lld",b.a[tot]);}
            }
            if(!flag) printf("0");
        //    putchar(10);
        //    printf("m:%d
    ",m);
        }
        inline overload operator-(overload&b){
            overload c=*this;
            for(int i=1;i<=1000;i++){
                if(c.a[i]-b.a[i]<0){
                    c.a[i+1]--;
                    c.a[i]=maxn+c.a[i]-b.a[i];
                }
                else c.a[i]=c.a[i]-b.a[i];
            }
            return c;
        }
        inline overload operator+(overload&b){
            overload c=b;
            for(int i=1;i<=1000;i++){
                c.a[i]+=a[i];
                c.a[i+1]+=c.a[i]/maxn;
                c.a[i]%=maxn;
            }
            return c;
        }
        inline overload operator*(overload&b){
            overload p;
            for(int i=1;i<=2500;i++){
                if(a[i]!=0) {
                    for(int j=1;j<=2500;j++){
                        if((p.a[j+i-1]+=a[i]*b.a[j])>(maxn-1)) {
                            p.a[j+i]+=p.a[j+i-1]/maxn;
                            p.a[j+i-1]=p.a[j+i-1]%maxn;
                        }
                    }
                }
            }
            return p;
        }
    
        inline overload operator^(overload p){
            int n=p.a[1];
            overload base(*this),ans(1); 
            while(n){
                if(n&1) ans=ans*base;
                base=base*base;
                n=n/2;
            }
            return ans;
        }
    };
    int main(){
        overload  c,b,d,a;
    //    int b;
        read(b);
        read(c);
        read(d);
        read(a);
        print(c+b);
        print(c*b);
        print(b-c);          
        print((b+c)^(a-d));
        
        return 0;
    }
    operator
  • 相关阅读:
    ID的插入
    开发语言的选择
    象数据库一样连接EXCEL
    前端,你真的了解JavaScript吗?
    开源软件与自由软件
    在codeigniter中使用Cache_Lite来缓存
    使用Codeigniter的SMTP类发Email
    JavaScript变量和数据类型
    JavaScript的隐式声明和变量声明提升的总结
    ASCII和UNICODE编码以及UTF8,你懂的?
  • 原文地址:https://www.cnblogs.com/Fish-/p/8379444.html
Copyright © 2020-2023  润新知