写在前面:

  一个小专题

  完全非原创,不知道原来是谁提出的

  诈尸

http://thepingaslord.deviantart.com/art/The-Evening-Prior-312446336


  • FR0X01
 1 #include<bits/stdc++.h>
2
3 using namespace std;
4
5 int a,b;
6 double c,d;
7
8 void readint(int &x){
9 x=0;int neg=1;
10 char c=getchar();
11 while(c<'0'||c>'9'){
12 if(c=='-') neg=-1;
13 c=getchar();
14 }
15 while(c>='0'&&c<='9'){
16 x=10*x+c-'0';
17 c=getchar();
18 }
19 x*=neg;
20 return;
21 }
22
23 void read(double &x){
24 x=0;double y=0.1,neg=1.0;
25 char c=getchar();
26 while(c<'0'||c>'9'){
27 if(c=='-') neg=-1.0;
28 c=getchar();
29 }
30 while(c>='0'&&c<='9'){
31 x=10*x+c-'0';
32 c=getchar();
33 }
34 if(c=='.'){
35 c=getchar();
36 while(c>='0'&&c<='9'){
37 x+=y*(c-'0');
38 y/=10;
39 c=getchar();
40 }
41 }
42 x*=neg;
43 return;
44 }
45
46 int main()
47 {
48 readint(a);readint(b);
49 read(c);read(d);
50
51 printf("%d\n%d\n",a,b);
52 printf("%lf\n%lf\n",c,d);
53
54 return 0;
55 }
  • FR0X02不定长度
#include<bits/stdc++.h>

using namespace std;

char getint(int &x){
x=0;int neg=1;
char c=getchar();
while(c<'0'||c>'9'){
if(c=='-') neg=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
x=10*x+c-'0';
c=getchar();
}
x=x*neg;
return c;
} int main()//利用快读读不定个数
{
int x,y,w;
for(int i=1;i<=3;++i)
{
char c;w=0;
getint(x);c=getint(y);
if(c!='\n') getint(w);
if(w) printf("%d %d %d\n",x,y,w);
else printf("%d %d\n",x,y);
}
return 0;
}
  • AdvancedFR
 1 #include<iostream>
2 #include<cstdio>
3
4 using namespace std;
5
6 inline char GC(){
7 static char buf[100010],*p1=buf,*p2=buf;
8 return (p1==p2&&(p2=(p1=buf)+fread(buf,1,100010,stdin),p1==p2))? EOF:*p1++;
9 }
10
11 void READ(int &x){
12 x=0;int neg=1;char c=GC();
13 while(c<'0'||c>'9'){if(c=='-')neg=-1;c=GC();}
14 while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c-'0');c=GC();}
15 x*=neg;
16 }
17
18 int main(int arg,char *argv[],char *enc[])
19 {
20 freopen("game.in","r",stdin);freopen("game.out","w",stdout);
21
22 fclose(stdin);fclose(stdout);
23 return 0;
24 }

(NOIP2018亲测能用)

例子:

 1 #include<bits/stdc++.h>
2 #define reg register
3 using namespace std;
4
5 int U_Rarity;
6 char E_Pie[10010];
7
8 inline char GC(){
9 static char buf[100010],*p1=buf,*p2=buf;
10 return (p1==p2&&(p2=(p1=buf)+fread(buf,1,100010,stdin),p1==p2))? EOF:*p1++;
11 }
12
13 int main(int arg,char *argv[],char *enc[]){
14 freopen("winterwrapup.in","r",stdin);freopen("winterwrapup.out","w",stdout);
15
16 int E_Pie_len=0;
17 for(reg int i=1;i<=10000;++i){
18 E_Pie[i]=GC();
19 ++E_Pie_len;
20 if(E_Pie[i]==10) break;
21 }
22 for(reg int i=1;i<=E_Pie_len;++i) printf("%c",E_Pie[i]);
23 printf("\nLength:%d",E_Pie_len);
24
25 fclose(stdin);fclose(stdout);
26 return 0;
27 }

比速度的话,AdvancedFR能够吊打基础快读

C++快读的更多相关文章

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

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

  2. C++手写快读详解(快速读入数字)

    众所周知,C++里是自带读入的(这不废话吗) 例如: int a; cin>>a; 这样的读入理解简单,适合初学者,但是非常慢. 再例如: int a; scanf("%d&qu ...

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

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

  4. C/C++快读(快速读入)有多——安全AC

    在一些算法题目中中,有的程序会被卡常(数),就是说,程序虽然渐进复杂度,(通俗来讲:算法的时间复杂度)可以接受,但因为算法本身的时间常数过大,导致程序在一些算法竞赛中超时.这是,快读就显得尤为重要了. ...

  5. C++读入神器——文操快读(oj也可以用)

    当某天,本蒟蒻沉迷于卡常的时候: 我-- 突然,YYKdalao说:用文操快读啊! 然后 喔-目瞪口呆 不多说,上源码: 本来用的读入方式: inline void Read( int &x ...

  6. int快读

    昨天偶然间看到CJ_tony的快读,所以便决定学习一下. 这个快读的原理就是:读入单个字符要比读入读入数字快,先读入字符,然后再转化成数字.(原理的话大学再研究) 代码: #include<io ...

  7. c++快读与快输模板

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

  8. c++ 快读快输模板

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

  9. C++快读模板

    C++的快速读入模板 inline int read() { ; char ch = getchar(); ') { if (ch == '-') flag = true; ch = getchar( ...

  10. [C/C++]快速读入代码(快读)

    快读 1.为什么要有快读 好吧,有些题目看上去十分简单,例如https://www.luogu.com.cn/problem/P4305这道题,实际上数据量巨多,光是一个测试点就可能有几个MB,在这种 ...

随机推荐

  1. xtrabackup不完全恢复

    例如,在2014年6月26日下午14:00的时候有人误操作drop掉了一张表,由于库不是很大,并且为测试库,并没有访问,这个时候,我们可以进行基于位置和时间点的不完全恢复 先找到早上的备份,查看那xt ...

  2. Kubernetes 升级过程记录:从 1.17.0 升级至最新版 1.20.2

    本文记录的是将 kubernetes 集群从 1.17.0 升级至最新版 1.20.2 的实际操作步骤,由于 1.17.0 无法直接升级到 1.20.2,需要进行2次过滤升级,1.17.0 -> ...

  3. bootstrap 后端模板

    Twitter Bootstrap 框架已经广为人知,用于加快网站,应用程序或主题的界面开发,并被公认为是迄今对于 Web 开发的最有实质性帮助的工具之一.在此之前的,各种各样的界面库伴随着高昂的维护 ...

  4. 24v转3.3v稳压芯片,高效率DC-DC变换器3A输出电流

    PW6206系列是一个高精度,高输入电压低静态电流,高速,低功耗降线性稳压器具有高纹波抑制.输入电压高达40V,负载电流为在VOUT=5V和VIN=7V时高达300mA.该设备采用BCD工艺制造.PW ...

  5. pandas模块的使用详解

    为什么学习pandas numpy已经可以帮助我们进行数据的处理了,那么学习pandas的目的是什么呢? numpy能够帮助我们处理的是数值型的数据,当然在数据分析中除了数值型的数据还有好多其他类型的 ...

  6. 获取Java线程转储的常用方法

    1. 线程转储简介 线程转储(Thread Dump)就是JVM中所有线程状态信息的一次快照. 线程转储一般使用文本格式, 可以将其保存到文本文件中, 然后人工查看和分析, 或者使用工具/API自动分 ...

  7. [从源码学设计] Flume 之 memory channel

    [从源码学设计] Flume 之 memory channel 目录 [从源码学设计] Flume 之 memory channel 0x00 摘要 0x01 业务范畴 1.1 用途和特点 1.2 C ...

  8. Manachar’s Algorithm

    Manachar's Algorithm Longest palindromic substring - Wikipedia  https://en.wikipedia.org/wiki/Longes ...

  9. Python_1生成器(下)之单线并行--生产着消费者模型

    1 import time 2 def consumer(name): 3 print('%s准备吃包子了!' %name) 4 while True: 5 baozi = yield 6 print ...

  10. aio 系列函数是由 POSIX 定义的异步操作接口,可惜的是,Linux 下的 aio 操作,不是真正的操作系统级别支持的,它只是由 GNU libc 库函数在用户空间借由 pthread 方式实现的,而且仅仅针对磁盘类 I/O,套接字 I/O 不支持。

    30 | 真正的大杀器:异步I/O探索 https://time.geekbang.org/column/article/150780