输出读入优化——QAQ
#include<bits/stdc++.h>
const int RN=1e5;
char ib[RN+],*ip=ib+RN,ob[RN+],*op=ob;
inline int gc(){
ip==ib+RN?fread(ip=ib,,RN,stdin)[ib]=:;
return*ip++;
}
struct IO{
void flush(){
fwrite(ob,,op-ob,stdout),op=ob;
}
template<class T>//T=int,long long
IO&operator>>(T&x0){
T x=;
int f=;
if(ip<ib+RN-){
while(*ip<)*ip++=='-'?f=-:;
while(*ip>)x=x*+*ip++-;
}else{
int c=gc();
while(c<)c=='-'?f=-:;
while(c>)x=x*+c-,c=gc();
}
x0=x;
return *this;
}
IO&operator>>(char*s){
int c=gc();
while(c<)c=gc();
while(c>)*s++=c,c=gc();
*s=;
return *this;
}
template<class T>//T=int,long long,char
IO&operator<<(T x){
if(op>ob+RN)flush();
int ss[],sp=;
if(x<)*op++='-',x=-x;
do ss[++sp]=+x%;while(x/=);
while(sp)*op++=ss[sp--];
return *this;
}
IO&operator<<(char x){
if(op>ob+RN)flush();
*op++=x;
return *this;
}
IO&operator<<(const char*str){
int n=strlen(str);
if(op+n>ob+RN)flush();
if(n<RN)memcpy(op,str,n),op+=n;
else fwrite(str,,n,stdout);
return *this;
}
IO&operator<<(char*str){
return *this<<(const char*)str;
}
IO&operator<<(std::string str){
return *this<<str.data();
}
}io;
int main(){
freopen("in.txt","r",stdin);
int a,b;
io>>a>>b;
io<<a<<'+'<<b<<'='<<a+b<<'\n';
io<<"test_string_output\n";
char s[];
io>>s;
io<<s<<'\n';
io.flush();
freopen("o.txt","w",stdout);
for(int i=;i<;++i)io<<i<<' ';
io.flush();
return ;
}
输出读入优化——QAQ的更多相关文章
- c++ 读入优化、输出优化模板
0. 在有些输入数据很多的变态题中,scanf会大大拖慢程序的时间,cin就更慢了,所以就出现了读入优化.其原理就是一个一个字符的读入,输出优化同理,主要使用getchar,putchar函数. 1. ...
- 读入优化&输出优化
读入优化 int read() { ; ') ; '; ') num=num*+c-'; return ff*num; } 输出优化 void write(int x) { ) { putchar(' ...
- C++ 读入优化&输出优化
读入优化:读入优化只是针对整数,由于getchar()读字符非常的快,所以采用getchar()来进行读入,下设输入的数为x 负数处理:用一个标志变量f,开始时为1,当读入了'-'时,f变为-1,最后 ...
- fread读入优化,寻找速度极限
序: 在之前的测试中,我们比较了四种读入方式,发现使用读入优化是最快的选择,但是我们知道fread()是比它更快的方法.这一次,我们对比四种读入优化,探寻C++读取速度的极限. 分别是getchar( ...
- c++读入优化
对于输入数据非常大的一些可(变)爱(态)题目,scanf就会大大拖慢程序的运行速度,cin就更不用说了,所以我们要用一种高大上的东西——读入优化. 读入优化的原理其实就是一个一个字符的读入,再组成数字 ...
- OI黑科技:读入优化
利用getchar()函数加速读入. Q:读入优化是什么? A :更加快速地读入一些较大的数字. Q:scanf不是已经够快了吗? A:Naive,scanf还是不!够!快! Q:那怎么办呢? A:我 ...
- ACM:读入优化
两个简单的读入优化 int getin(){ ;; while(!isdigit(tmp=getchar()) && tmp!='-'); ,tmp=getchar(); )+(ans ...
- 【ACM非算法部分】读入优化
今天做了ACdream的比赛才知道原来还有读入优化这一说.Orz 读入一个整数的时候这么写: int a; scanf("%d",&a); 和 int a; char c; ...
- 【CSP模拟赛】天才绅士少女助手克里斯蒂娜(线段树&读入优化&输出优化)
题面描述 红莉栖想要弄清楚楼下天王寺大叔的显像管电视对“电话微波炉(暂定)”的影响.选取显像管的任意一个平面,一开始平面内有个n电子,初始速度分别为vi,定义飘升系数为 $$\sum_{1\leqsl ...
随机推荐
- python flask豆瓣微信小程序案例
项目步骤 定义首页模板index.html <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- Snowflake Snow Snowflakes【Poj3349】
Description You may have heard that no two snowflakes are alike. Your task is to write a program to ...
- Samba和NFS文件共享
SAMBA文件共享服务 通过Yum软件仓库来安装Samba服务程序 [root@zhangjh ~]# yum install samba -y Samba 配置文件注释信息较多,为了便于配置,因此先 ...
- eclipse包名分层级显示
eclipse包名像文件列表那样显示设置方法
- Result Maps collection does not contain value for xxxx
这是mybatis查询返回值的错误,我在做一个查询数值的方法,但是我是这样写的: <select id="findSize" resultMap="long&quo ...
- luogu4196 [CQOI2006]凸多边形 半平面交
据说pkusc出了好几年半平面交了,我也来水一发 ref #include <algorithm> #include <iostream> #include <cstdi ...
- [转] PHP在不同页面之间传值的三种常见方式
转自: http://my.oschina.net/jiec/blog/196153 一. POST传值 post传值是用于html的<form>表单跳转的方法,很方便使用.例如: < ...
- python学习笔记三:函数及变量作用域
一.定义 def functionName([arg1,arg2,...]): code 二.示例 #!/usr/bin/python #coding:utf8 #coding=utf8 #encod ...
- Jmeter日期
有的时候我们接口中会有需要传递日期的参数,这是jmeter工具中给我准备一个 日期函数_time,如下图所示: 取到的将会是年月日 对应的写法有 yyyy-MM-dd HH:mm:ss ---年月日 ...
- 你的第一个自动化测试:Selenium 自动化测试
前言: 让你掌握自动化测试暂时脱离手工点点点,本章节让你掌握 Selenium 如何定位.判定.操作元素(实现业务逻辑) 一. 前期准备 1.准备以下工具 1.Selenium下载地址:立即下载 2. ...