zoukankan      html  css  js  c++  java
  • IO 优化

    转自 BlackJack_

    #define fastcall __attribute__((optimize("-O3")))
    #define IL __inline__ __attribute__((always_inline))
     
    #ifdef ONLINE_JUDGE
    char *TT,*mo,but[(1<<15)+2];
    #define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin)),TT==mo)?0:*TT++)
    #endif
    fastcall IL int read()
    {
    	int x=0,ch=0;
    	while(ch<'0'||ch>'9')ch=getchar();
    	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    	return x;
    }
    fastcall void print(int x)
    {if(x<0)putchar('-'),x=-x;if(x>=10)print(x/10);putchar(x%10+'0');}
    
    
    #include <cstdio>
     
    using namespace std;
     
    namespace io {
    	const int SIZE = (1 << 21) + 1;
    	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
    	// getchar
    	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
    	// print the remaining part
    	inline void flush () {
    		fwrite (obuf, 1, oS - obuf, stdout);
    		oS = obuf;
    	}
    	// putchar
    	inline void putc (char x) {
    		*oS ++ = x;
    		if (oS == oT) flush ();
    	}
    	// input a signed integer
    	template <class I>
    	inline void gi (I &x) {
    		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
    		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
    	}
    	// print a signed integer
    	template <class I>
    	inline void print (I &x) {
    		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
    		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
    		while (qr) putc (qu[qr --]);
    	}
    }
    using io :: gi;
    using io :: putc;
    using io :: print;
     
    int v;
     
    int main () {
    	gi (v);
    	print (v);
    	putc ('
    ');
    	io :: flush ();
    }
    
    
  • 相关阅读:
    <!DOCTYPE html>的重要性!
    ibatis 常用标签
    string.match(RegExp) 与 RegExp.exec(string) 深入详解
    JavaScript RegExp.$1
    JavaScript RegExp.exec() 方法
    正则表达式常用符号说明
    正则表达式中/i,/g,/ig,/gi,/m的区别和含义
    JavaScript Math.floor() 方法
    JavaScript RegExp.test() 方法
    js日期格式化 扩展Date()
  • 原文地址:https://www.cnblogs.com/SGCollin/p/10271116.html
Copyright © 2011-2022 走看看