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元大奖)

C++ 加速(卡常)技巧【超级 快读、快写】的更多相关文章

  1. 快读&快写模板【附O2优化】

    快读&快写模板 快读快写,顾名思义,就是提升输入和输出的速度.在这里简单介绍一下几种输入输出的优劣. C++ cin/cout 输入输出:优点是读入的时候不用管数据类型,也就是说不用背scan ...

  2. P1908 逆序对——树状数组&离散化&快读快写の学习

    题目简述: 对于给定的一段正整数序列,逆序对就是序列中 a_i>a_jai​>aj​ 且 i<ji<j 的有序对. 输出序列中逆序对的数目. 知识补充: 树状数组: 这东西就是 ...

  3. 卡常三连(快读快写+re)

    快读: inline int in() { char ch; ; '))); a*=;a+=ch-'; ,a+=ch-'; return a; } 快写: inline void out(int a) ...

  4. c++ 快读快输模板

    快读 inline int read() { ; ; char ch=getchar(); ; ch=getchar();} )+(X<<)+ch-'; ch=getchar();} if ...

  5. CodeForces 327E Axis Walking(状压DP+卡常技巧)

    Iahub wants to meet his girlfriend Iahubina. They both live in Ox axis (the horizontal axis). Iahub ...

  6. C++笔记——快读快写

    直接开始吧 额m~,这里就没什么好说的了,无非就是用getchar加快cin或printf的读入速度. 代码: inline int read() { int X=0; bool flag = 1; ...

  7. C++ 快读快写

    inline int read() { int s=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; c ...

  8. 打FFT时中发现的卡常技巧

    题目:洛谷P1919 A*B Problem 加强版 我的代码完全借鉴boshi,然而他380ms我880ms...于是我通过彻底的卡(chao)常(dai)数(ma)成功优化到了380ms,都是改了 ...

  9. Codeforces 986D - Perfect Encoding(FFT+爪巴卡常题)

    题面传送门 题意:给出 \(n\),构造出序列 \(b_1,b_2,\dots,b_m\) 使得 \(\prod\limits_{i=1}^mb_i\geq n\),求 \(\sum\limits_{ ...

随机推荐

  1. 一条更新的SQL如何执行

    开源Linux 一个执着于技术的公众号 一条SQL的执行流程如图所示 如图所示:MySQL数据库主要分为两个层级:服务层和存储引擎层 •服务层:server层包括连接器.查询缓存.分析器.优化器.执行 ...

  2. 全网显示 IP 归属地,这背后的技术你知道吗?

    为了进一步规范国内的网络舆论,国家规定了各互联网平台都需要显示 IP 归属地信息.微博.抖音.公众号等多个平台纷纷上线了 IP 归属地功能,这标志着国内言论的进一步规范化.但互联网平台商们是怎么通过 ...

  3. C++进阶-3-5-set/multiset容器

    C++进阶-3-5-set/multiset容器 1 #include<iostream> 2 #include<set> 3 using namespace std; 4 5 ...

  4. Java学习笔记-基础语法Ⅴ

    学习一些Java常用的API Math:包含执行基本数字运算的方法 如果没有构造方法,一般类的成员都是静态的,通过类名可以直接调用 Java中有两种random函数,Math.Random()函数能够 ...

  5. zabbix 1.1

    1.zabbix监控平台 2.zabbix的三部分组件:      Zabbix server 是 Zabbix软件的核心组件,agent 向其报告可用性.系统完整性信息和统计信息.server也是存 ...

  6. netty系列之:使用Jboss Marshalling来序列化java对象

    目录 简介 添加JBoss Marshalling依赖 JBoss Marshalling的使用 总结 简介 在JAVA程序中经常会用到序列化的场景,除了JDK自身提供的Serializable之外, ...

  7. MongoDB 分片集群

    每日一句 Medalist don't grow on trees, you have to nurture them with love, with hard work, with dedicati ...

  8. 5分钟快速搭建一个springboot的项目

      现在开发中90%的人都在使用springboot进行开发,你有没有这样的苦恼,如果让你新建一个springboot开发环境的项目,总是很苦恼,需要花费很长时间去调试.今天来分享下如何快速搭建. 一 ...

  9. Random 中的Seed

    C#中使用随机数 看下例 当Random的种子是0时 生成的随机数列表是一样的 也就是说当seed 一样时 审查的随机数时一样的 Random的无参实例默认 种子 时当前时间 如果要确保生成的随机数不 ...

  10. drools决策表的简单使用

    目录 一.背景 二.一个简单的决策表 1.在同一个决策表中处理多个Sheet页 2.RuleSet下方可以有哪些属性 3.RuleTable下方可以有哪些属性 4.规则属性的编写 三.需求 四.实现 ...