写在前面:

  一个小专题

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

  诈尸

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. Linux 入门教程:00 Background

    Linux 为何物? 就是一个操作系统. Linux 历史: 操作系统始于二十世纪五十年代,当时的操作系统能运行批处理程序.批处理程序不需要用户的交互,它从文件或者穿孔卡片读取数据,然后输出到另外一个 ...

  2. 【Java】集合综合案例 - 播放器管理

    集合综合案例 文章目录 集合综合案例 需求分析 项目演示 详细设计 代码实现 歌曲类 播放器类 播放列表类 测试 参考资料 播放器管理 需求分析 项目演示 详细设计 代码实现 重新搞一波 复习巩固 简 ...

  3. 创建mysql帐户

    CREATE USER 'username'@'host' IDENTIFIED BY 'password';

  4. QLibrary 加载动态库

    阅读本文大概需要 6.6分钟 一般情况下在没有头文件支持情况下,想要引入某个动态库,最好的办法就是使用「动态加载」的方法,在Qt中一般使用QLibyary来操作 常用 api QLibrary(con ...

  5. 优先队列priority_queue排序

    优先队列默认大顶堆,即堆顶元素是最大值 改成小顶堆时: priority_queue<int,vector<int>, greater<int> > Q;//注意最 ...

  6. 在Firefox上使用Chrome的crx扩展程序

    假如你喜欢使用Firefox火狐浏览器,可是发现有个很喜欢很想用的扩展只发布了支持Chrome的crx格式--Firefox从57版以后使用了WebExtension API作为新附加组件的开发标准, ...

  7. 并发编程之fork/join(分而治之)

    1.什么是分而治之 分而治之就是将一个大任务层层拆分成一个个的小任务,直到不可拆分,拆分依据定义的阈值划分任务规模. fork/join通过fork将大任务拆分成小任务,在将小任务的结果join汇总 ...

  8. http://golang.org/s/better-linker

    http://golang.org/s/better-linker The original linker was also simpler than it is now and its implem ...

  9. OPC UA 统一架构) (一)

    OPC UA 一 .OPC UA简介 OPC UA(OPC Unified Architecture)是下一代OPC统一体系架构,是一种基于服务的.跨越平台的解决方案. OPC UA具有如下特点: 1 ...

  10. POJ2029 二维线段树

    Get Many Persimmon Trees POJ - 2029 Seiji Hayashi had been a professor of the Nisshinkan Samurai Sch ...