大整形__int128 使用——模板

  • 使用注意
  1. 只能用在 Linux 系统的 oj 上,
  2. 数据表示的数据范围最大可以是:85070591730234615865843651857942052864(8e37)即:(1 <<126)
  3. 自己定义输入输出函数:scan、print
  4. __int128 占 sizeof (__int128)=16 字节

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <vector>
void fre() { system("clear"), freopen("A.txt", "r", stdin); freopen("Ans.txt","w",stdout); }
void Fre() { system("clear"), freopen("A.txt", "r", stdin);}
void Run(int x = 0)      
{// 宏定义免注释 freopen
#ifdef ACM 
    if(! x) fre(); else Fre();
#endif
}
#define ios ios::sync_with_stdio(false)
#define Pi acos(-1)
#define pb push_back
#define fi first
#define se second
#define db double
#define ll long long
#define ull unsigned long long
#define Pir pair<ll, ll>
#define m_p make_pair
#define for_(i, s, e) for(ull i = (ll)(s); i <= (ll)(e); i ++)
#define rep_(i, e, s) for(ll i = (ll)(e); i >= (ll)(s); i --)
#define memset(ar, b, c) memset(ar, (int)b, c);
#define size() size() * 1LL
#define sc scanf
#define pr printf
#define sd(ar) scanf("%lld", &ar)
#define ss(ar) scanf("%s", ar)
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define esp 1e-7
#define mod (ll)(1000)
using namespace std;
/*=========================ACMer===========================*/

void print(__int128 x)
{
    if(x < 0)
    {
        x = -x;
        putchar('-');
    }
    if(x > 9) print(x/10);
    putchar(x%10 + '0');
}

void scan(__int128 &x)
{
    x = 0;
    int f = 1;
    char ch;
    if((ch = getchar()) == '-') f = -1;
    else x = x * 10 + ch - '0';
    while((ch = getchar()) >= '0' && ch <= '9') x = x * 10 + ch - '0';
    x *= f;
}

int main()
{
    __int128 a = 1;
    __int128 b = (a << 64);
    print(b);

    return 0;
}
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值