C++ 加速(卡常)技巧【超级 快读、快写】

C++ 加速(卡常)技巧【超级 快读、快写】,第1张

C++ \texttt{C++} C++ 加速技巧 快读快写 快读
inline int read()
{
    int x = 0, w = 0; char ch = 0;
    while (!isdigit(ch)) {w |= ch == '-'; ch = getchar();}
    while (isdigit(ch)) {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
    return w ? -x : x;
}
快写
inline void write(int x)
{
     if (x < 0) putchar('-'), x = -x;
     if (x > 9) write(x / 10);
     putchar(x % 10 + '0');
}
超级快读快写
namespace IO

{
int len = 0;
char ibuf[(1 << 20) + 1], *iS, *iT, out[(1 << 25) + 1];
#define gh()                                                                   \
	(iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, (1 << 20) + 1, stdin),       \
	(iS == iT ? EOF : *iS++) : *iS++)
#define reg register
inline int read()
{
	reg char ch = gh();
	reg int x = 0;
	reg char t = 0;
	while (ch < '0' || ch > '9')
		t |= ch == '-', ch = gh();
	while (ch >= '0' && ch <= '9')
		x = x * 10 + (ch ^ 48), ch = gh();
	return t ? -x : x;
}
inline void putc(char ch)
{
	out[len++] = ch;
}
template  inline void write(T x)
{
	if (x < 0)
		putc('-'), x = -x;
	if (x > 9)
		write(x / 10);
	out[len++] = x % 10 + 48;
}
inline void flush()
{
	fwrite(out, 1, len, stdout);
	len = 0;
}
}
using IO::flush;
using IO::putc;
using IO::read;
using IO::write;

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/676428.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-19
下一篇 2022-04-19

发表评论

登录后才能评论

评论列表(0条)

保存