写在前面:

  一个小专题

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

  诈尸

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. Soat控制HAProxy 动态增减服务器

    Soat控制HaProxy 动态增减服务器 安装HaProxy-1.5.18: yum install haproxy -y yum install socat -y HaProxy-1.5.18 配 ...

  2. 深入汇编指令理解Java关键字volatile

    volatile是什么 volatile关键字是Java提供的一种轻量级同步机制.它能够保证可见性和有序性,但是不能保证原子性 可见性 对于volatile的可见性,先看看这段代码的执行 flag默认 ...

  3. linux系统Vsftpd搭建FTP

    安装vsftp 使用yum命令安装vsftp #yum install vsftpd -y 添加ftp帐号和目录 先检查下nologin的位置,通常在/usr/sbin/nologin下   (*no ...

  4. MongoDB分片集群部署方案

    前言 副本集部署是对数据的冗余和增加读请求的处理能力,却不能提高写请求的处理能力:关键问题是随着数据增加,单机硬件配置会成为性能的瓶颈.而分片集群可以很好的解决这一问题,通过水平扩展来提升性能.分片部 ...

  5. [Usaco2008 Nov]Buying Hay 购买干草

    题目描述 约翰的干草库存已经告罄,他打算为奶牛们采购H(1≤H≤50000)磅干草,他知道N(1≤N≤100)个干草公司,现在用1到N给它们编号.第i个公司卖的干草包重量为Pi(1≤Pi≤5000)磅 ...

  6. nmap的理解与利用(初级)

    在命令窗口下输入命令等待,可以用回车来查看进度 nmap进行探测之前要把域名通过dns服务器解析为ip地址,我们也可以使用指定的dns服务器进行解析. nmap --dns-servers 主机地址 ...

  7. UI测试框架

    1. 从上到下共分成4层: 用例层  组件管理层  元素管理层  公共数据层 2. 用例层: 将每条用例使用参数化, 公共参数存储到"公共数据层", 中间参数通过组件层传递 3. ...

  8. windows中使用django时报错:A server error occurred. Please contact the administrator.

    这是因为在视图函数中使用了get函数,获取了不存在的数据例如:数据库中不存在一条name为hello1的数据,使用如下语句访问message = Message.objects.get(name='h ...

  9. 我为什么不鼓吹 WireGuard

    原文链接:https://fuckcloudnative.io/posts/why-not-wireguard/ 最近有一款新型 VPN 工具备受瞩目,相信很多人已经听说过了,没错就是 WireGua ...

  10. (hive)hive优化(转载)

    1. 概述 1.1 hive的特征: 可以通过SQL轻松访问数据的工具,从而实现数据仓库任务,如提取/转换/加载(ETL),报告和数据分析: 它可以使已经存储的数据结构化: 可以直接访问存储在Apac ...