跳到正文

算法·理论

__int128快读快写

Dreamalice约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月9日
篇幅
约 2 分钟
获赞
1

版本

  1. v1当前

__int128

比 unsigned long long 略微大一些些,可以断定,小于38位

A*B problem

C++
#include <bits/stdc++.h>
#define ll long long
#define int __int128
using namespace std;
int read() { //快读
	char c = getchar();
	int x = 0, f = 1;
	while (c < '0' || c > '9') {
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - '0';
		c = getchar();
	}
	return x * f;
}
void print(int x) { //快写
	if (x == 0) {
		putchar('0');
		return ;
	}
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	char buff[50];
	int lenth = 0;
	while (x) {
		buff[lenth++] = x % 10 + '0';
		x /= 10;
	}
	for (int i = lenth - 1; i >= 0; i--)putchar(buff[i]);
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	a = read();
	b = read();
	print(a * b);
	return 0;
}
原文