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. python操作MySQL、事务、SQL注入问题

    python操作MySQL python中支持操作MySQl的模块很多 其中最常见就是'pymysql' # 属于第三方模块 pip3 install pymysql # 基本使用 import py ...

  2. 资讯:IEEE1

    IEEE 2020 年 12 大技术趋势:边缘计算.量子计算.AI.数字孪生等 2020-02-06 以下是对2020年12大技术趋势的预测.IEEE计算机协会自2015年以来一直在预测技术趋势,其年 ...

  3. 封装axios请求

    import axios from 'axios' import router from '@/router' axios.defaults.baseURL = system.requestBaseU ...

  4. Java基础(1)——ThreadLocal

    1. Java基础(1)--ThreadLocal 1.1. ThreadLocal ThreadLocal是一个泛型类,当我们在一个类中声明一个字段:private ThreadLocal<F ...

  5. Redis中的原子操作(2)-redis中使用Lua脚本保证命令原子性

    Redis 如何应对并发访问 使用 Lua 脚本 Redis 中如何使用 Lua 脚本 EVAL EVALSHA SCRIPT 命令 SCRIPT LOAD SCRIPT EXISTS SCRIPT ...

  6. Jmeter之测试片段--include控制器进行接口测试以及管理测试用例

    1.线程组--右键添加--测试片段--测试片段 2.在测试片段中进行添加测试用例如下图: 3.通过include控制器进行调用测试片段 (通常使用全局) 选择线程组--右键添加--逻辑控制器--Inc ...

  7. c++ FHQ Treap

    前面我们对平衡树有了个大概的了解 关于 Treap Treap=Binary Search Tree + Heap 二叉搜索树 + 二叉堆(一般是小根堆) Treap 每一个节点有两个值 一个值是平衡 ...

  8. 整数分解、for循环阶乘

    整数分解 整数分解是什么呢??我们可以这样理解 我们写一个 3位数求出它的个位十位和百位 . 那么我们来写一个小的测试来看一下! public static void main(String[] ar ...

  9. ShardingSphere 异构迁移最佳实践:将3.5亿量级的顾客系统 RTO 减少60倍

    Apache ShardingSphere 助力当当 3.5 亿用户量级顾客系统重构,由 PHP+SQL Server 技术栈无缝转型为 Java+ShardingSphere+MySQL,性能.可用 ...

  10. 拙见--springMVC的controller接受的请求参数

    1-这种是最常用的表单参数提交,ContentType指定为application/x-www-form-urlencoded,也就是会进行URL编码. 1.1-对象类型实体Bean接收请求参数(表单 ...