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 ();
    }
    
    
  • 相关阅读:
    命名空间
    XML
    关于命名空间
    gitbook 入门教程之 gitbook 简介
    git 入门教程之备忘录[译]
    git 入门教程之知识速查
    git 入门教程之忽略文件
    git 入门教程之个性化 git
    git 入门教程之里程碑式标签
    git 入门教程之本地和远程仓库的本质
  • 原文地址:https://www.cnblogs.com/SGCollin/p/10271116.html
Copyright © 2011-2022 走看看