跳到正文

个人记录

快读

面条小王子约 3 分钟
原文

这是 2025年9月26日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2025年9月18日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 3 分钟

版本

  1. v2当前
  2. v1
  • int -2147483648~2147483647

    如果输入输出会有 -2147483648 (2^31) 记得开 long long

  • 只输入大写字母或小写字母可以修改快读字符串

  • 空格换行自己输

C++
namespace Fast_read
{
	// int -2147483648~2147483647
	// 如果输入输出会有 -2147483648 (2^31) 记得开 long long
	// 只输入大写字母或小写字母可以修改快读字符串 
	// 空格换行自己输 
	int op, stk[35], top = 0;
	char c;
	
	template <typename T>
	inline void read(T &w)
	{
		w = 0, op = 1;
		do {c = getchar();}while ((c < '0' || c > '9') && c != '-');
		if (c == '-') op = -1, c = getchar();
		do {w = (w << 1) + (w << 3) + (c ^ 48), c = getchar();}while (c >= '0' && c <= '9');
		w *= op;
	}
	
	inline int read()
	{
		int w = 0;
		op = 1;
		do {c = getchar();}while ((c < '0' || c > '9') && c != '-');
		if (c == '-') op = -1, c = getchar();
		do {w = (w << 1) + (w << 3) + (c ^ 48), c = getchar();}while (c >= '0' && c <= '9');
		return w * op;
	}
	
	template <typename T>
	inline void print(T ans)
	{
		top = 0;
		if (ans < 0) putchar('-'), ans = -ans;
		do {stk[ ++ top] = ans % 10, ans /= 10;}while (ans);
		while (top) putchar(stk[top -- ] ^ 48);
	}
	
	inline void read(char *s, int &len)
	{
		do {c = getchar();}while ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z'));
		do {s[ ++ len] = c, c = getchar();}while ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
	}
	
	inline void print(char *s, int &len)
	{
		top = 0;
		do {putchar(s[ ++ top]);}while (top <= len);
	}
}

using namespace Fast_read;