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. jQuery.extend()[$.extend()]

    jQuery.extend(target, object1[,objectN]);jQuery.extend([deep], target, object1[,objectN]);jQuery.ext ...

  2. 推荐三个好用的TamperMonkey洛谷插件

    Part 1: TamperMonkey 插件 Part 1.1 什么是 Tampermonkey 在我们学习的过程中,往往想要更多功能,这时候可以使用 TamperMonkey 插件进行美化 官网介 ...

  3. 查重工具Jplag的使用

    目录 前言 一.Jplag是什么? 二.使用步骤 1.下载包 2.java环境配置 3.如何使用 三.总结 前言 说明一下本文章针对最新版本Jplag3.0使用JplagAPI 一.Jplag是什么? ...

  4. PPP PPOE详解

    PPP协议是在串行线IP协议SLIP(Serial Line Internet Protocol)的基础上发展起来的.由于SLIP协议具有只支持异步传输方式.无协商过程(尤其不能协商如双方IP地址等网 ...

  5. 872. Leaf-Similar Trees - LeetCode

    Question 872. Leaf-Similar Trees Solution 题目大意: 如果两个二叉树的叶子节点相同就认为这两个二叉树相似.给两个二叉树判断是否相似. 思路: 用递归把两个二叉 ...

  6. Dockerfile指令与Docker-compose容器编排-搭建docker私有仓库

    目录 一:部署应用映射外部目录(持久化) 总结 二:迁移与备份(容器保存为镜像) 1.django执行gitee,项目提交到远端 2.其他操作 3.操作步骤 4.容器保存为镜像 5.把镜像打包成压缩包 ...

  7. unity---3D数学基础

    点乘 A·B 判断敌人在前方还是后方 调试画线 画线段 前两个参数 分别是 起点 终点 画射线 前两个参数 分别是 起点 方向 Debug.DrawLine(this.transform.positi ...

  8. Ajax前后端交互——后端接收前端页面变量

    核心代码: app.py from flask import Flask, render_template, request, jsonify app = Flask(__name__) @app.r ...

  9. 以圆类 Circle 及立体图形类 Solid 为基础设计圆锥类 Cone

    学习内容:以圆类 Circle 及立体图形类 Solid 为基础设计圆锥类 Cone 代码示例: import java.util.Scanner; class Point4{ private dou ...

  10. 数据分析工具Metabase--Metabase安装(最详细的安装教程)

    Meatabase介绍 Metabase 是一款开源的BI工具.主要可以实现在线的可视化分析,单独生成分析图标,定时刷新数据集,权限管理,报告分享等一系列功能. Metabase支持多种市面上主流的数 ...