WELCOME

任何一个伟大的目标,都有一个微不足道的开始。

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

 


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 <class T> 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;

广告

绿树公司 - 官方网站:https://wangping-lvshu.github.io/LvshuNew/

绿树智能 - 官方网站:https://wangping-lvshu.github.io/LvshuZhineng/

(现在使用,人人均可获得300元大奖)


__EOF__

本文作者绿树公司
本文链接https://www.cnblogs.com/wp-lvshu/p/16471602.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   绿树公司  阅读(880)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示