快速读入输出/__int128读入输出模板

快读模板:
_int128的读入和输出不能用cin或者scanf,必须自定义读入和输出(也就是快读)

inline __int128 read(){  //__int128 可以换成 int longlong 基于自己的需求即可
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
inline void out(__int128 x){    //输出
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)
        out(x/10);
    putchar(x%10+'0');
}

另一种算法处理爆longlong的情况:

	long long ans,m,mod=1e14;
	m+=b[r]*(s[r]-s[l]),ans+=m/mod,m%=mod;
	if(ans) printf("%lld%014lld\n",ans,m);
     else printf("%lld\n",m);

猜你喜欢

转载自blog.csdn.net/weixin_43872264/article/details/107792946