快速读入fread
struct FastIO {
static const int S = 1e7;
int wpos;
char wbuf[S];
FastIO() : wpos(0) {}
inline int xchar() {
static char buf[S];
static int len = 0, pos = 0;
if (pos == len)
pos = 0, len = fread(buf, 1, S, stdin);
if (pos == len) exit(0);
return buf[pos++];
}
inline int xuint() {
int c = xchar(), x = 0;
while (c <= 32) c = xchar();
for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
return x;
}
inline int xint()
{
int s = 1, c = xchar(), x = 0;
while (c <= 32) c = xchar();
if (c == '-') s = -1, c = xchar();
for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
return x * s;
}
inline void xstring(char *s)
{
int c = xchar();
while (c <= 32) c = xchar();
for (; c > 32; c = xchar()) * s++ = c;
*s = 0;
}
inline void wchar(int x)
{
if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
wbuf[wpos++] = x;
}
inline void wint(ll x)
{
if (x < 0) wchar('-'), x = -x;
char s[24];
int n = 0;
while (x || !n) s[n++] = '0' + x % 10, x /= 10;
while (n--) wchar(s[n]);
wchar('\n');
}
inline void wstring(const char *s)
{
while (*s) wchar(*s++);
}
~FastIO()
{
if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
}
} io;
快速读入fread的更多相关文章
- hdu6396 /// fread()快速读入挂
题目大意: 给定n k 给定主角具有的k种属性 给定n个怪兽具有的k种属性和打死该怪兽后能得到的k种属性对应增幅 求主角最多能打死多少怪兽和最终主角的k种属性 k最大为5 开5个优先队列贪心 快速读入 ...
- C/C++快读(快速读入)有多——安全AC
在一些算法题目中中,有的程序会被卡常(数),就是说,程序虽然渐进复杂度,(通俗来讲:算法的时间复杂度)可以接受,但因为算法本身的时间常数过大,导致程序在一些算法竞赛中超时.这是,快读就显得尤为重要了. ...
- [C/C++]快速读入代码(快读)
快读 1.为什么要有快读 好吧,有些题目看上去十分简单,例如https://www.luogu.com.cn/problem/P4305这道题,实际上数据量巨多,光是一个测试点就可能有几个MB,在这种 ...
- fread 快速读入 (神奇挂!)
注意这里是将后台的所有数据都读入在计算 #include<bits/stdc++.h> using namespace std; #define ll long long namespac ...
- 规模数据导入高效方式︱将数据快速读入R—readr和readxl包
本文由雪晴数据网负责翻译整理,原文请参考New packages for reading data into R - fast作者David Smith.转载请注明原文链接http://www.xue ...
- c++ 快速读入输出
1. 读入优化 C++中有一个函数:getchar() ,用于读入字符,那么这跟读入整数有什么关系呢? 其实,经过类似高精度的处理,就可以实现类型转换啦! 下面是正负数读入优化模板: #include ...
- C++手写快读详解(快速读入数字)
众所周知,C++里是自带读入的(这不废话吗) 例如: int a; cin>>a; 这样的读入理解简单,适合初学者,但是非常慢. 再例如: int a; scanf("%d&qu ...
- C++快速读入
使用C++的标准cin进行读入速度比较慢,尤其是在大数据的情况下,所以我们需要使用一种方法,按照字符读入,最后再"组装"成整数.由于字符读入比数字要快,所以这样做可以提高读入速度. ...
- NOIP2018出征策
蒟蒻的风之旅人即将退役,现在分享一下退休前的故事 首先,经过这么多时间的划水训练,我成功从一个萌新变成了一个蒟蒻.我学会了各种奇怪玄学的算法,比如说昨天老师讲的NOIP第三题通用的算法,叫做XG算法, ...
随机推荐
- jQuery 遍历 - eq() 方法 查找当前元素
jQuery 遍历 - eq() 方法 if(data[i].status !='已送达'){ $('.w-beget').eq(i).attr('disabled','disabled'); }
- Low-level Native Plugin Interface
http://docs.manew.com/Manual/index.htm https://docs.unity3d.com/Manual/NativePluginInterface.html ht ...
- 20145322 Exp5 Adobe阅读器漏洞攻击
20145322 Exp5 Adobe阅读器漏洞攻击 实验过程 IP:kali:192.168.1.102 windowsxp :192.168.1.119 msfconsole进入控制台 使用命令为 ...
- 20135234mqy-——信息安全系统设计基础第十一周学习总结
第八章 异常控制流 8.1异常 异常是异常控制流的一种形式,它一部分是由硬件实现的,一部分是由操作系统实现的. 异常就是控制流中的突变,用来响应处理器状态中的某些变化. 8.1.1异常处理 异常号是到 ...
- 在Android Studio中创建项目和模拟器
北京电子科技学院 实 验 报 告 课程:移动平台应用开发实践 班级:201592 姓名:杨凤 学号:20159213 成绩:___________ 指导老师:娄嘉 ...
- SpringJDBC源码分析记录
我们使用JdbcTemplate时,调用的query方法为: public <T> List<T> query(String sql, @Nullable Object[] a ...
- Open Source Log Management
https://www.elastic.co/solutions/logging The Elastic Stack (sometimes known as the ELK Stack) is the ...
- Codeforces Round #527 (Div. 3)
一场div3... 由于不计rating,所以打的比较浪,zhy直接开了个小号来掉分,于是他AK做出来了许多神仙题,但是在每一个程序里都是这么写的: 但是..sbzhy每题交了两次,第一遍都是对的,结 ...
- UVa 12219 公共表达式消除
https://vjudge.net/problem/UVA-12219 题意: 用表达式树来表示一个表达式. 思路: 用map来记录出现过的子树.如(b,3,6)表示这棵子树的根为b,左子树为编号为 ...
- perl usage()和getopt
#!/usr/bin/perl#perl search.pl --infile Targets.Lung.Carcinoma.genelist.txt --homogene Homo_sapiens. ...