首页 > 其他 > 详细

板子-__int128

时间:2020-11-20 15:10:14      阅读:43      评论:0      收藏:0      [点我收藏+]

__int128 是比 long long 还要大的数据类型(\(max = 2^{128}-1\)
其输入和输出不能用常规方法,用 read() 和 write() 函数代替

#include<bits/stdc++.h>

using namespace std;

__int128 read(int f = 1) {
    char ch = getchar();
    __int128 res = 0;
    while(ch > ‘9‘ || ch < ‘0‘) {
        if (ch == ‘-‘) f *= -1;
        ch = getchar();
    }
    while(ch <= ‘9‘ && ch >= ‘0‘) {
        res = res * 10 + (ch ^ 48);
        ch = getchar();
    }
    return res * f;
}

void write(__int128 n) {
    if (n < 0) {
        putchar(‘-‘);
        n *= -1;
    }
    if (n/10) write(n/10);
    putchar(n%10+‘0‘);
}

int main() {
    __int128 n = read();
    write(n);
    return 0;
}

板子-__int128

原文:https://www.cnblogs.com/yycx/p/14010350.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!