Gravatar
Benjamin
积分:1054
提交:405 / 658

Pro3508  [NOIP 2020]排水系统

__int128类型使用方法

该题大整数运算部分,可以使用 __int128 类型,该类型需要 自定义输入输出,详细方法请参考如下代码:

#include <bits/stdc++.h>
using namespace std;

typedef __int128 LL;

inline read(LL &x)//输入
{
  x = 0;
  LL f = 1;
  char ch;
  
  if((ch = getchar()) == '-')
    f = -f;
  else
    x = x*10 + ch-'0';
  
  while((ch = getchar()) >= '0' && ch <= '9')
    x = x*10 + ch-'0';
  
  x *= f;
}

inline print(LL x)//输出
{
  if(x < 0)
  {
    x = -x; putchar('-');
  }
  
  if(x>9) print(x/10);
  
  putchar(x%10+'0');
}

int main()
{
  LL a, b;
  read(a); read(b);
  print(a + b);
  return 0;
}

2023-10-27 14:04:50    
我有话要说
Gravatar
Komin
积分:16
提交:6 / 9
回复@Benjamin :????这个能过???大哥你连树都没存啊哥

2021-11-16 21:39:02    
Gravatar
Benjamin
积分:1054
提交:405 / 658

回复@Komin : 

你好,我发的程序只是介绍 __int128 的使用方法,针对这个题解题过程中的数会比较大,可以考虑采用__int128,也可以用其他方法处理大整数运算。


2023-10-25 23:06:00