普通输入输出外挂,虽然没有强力挂快 但是却更加实用
inline int read(){
int k=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
return k*f;
}
inline void write(int x){if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(int x){write(x);puts("");}
版本1
namespace IN
{
const int inBufferSize = 1<<25;
char inBuffer[inBufferSize];
char *inHead = NULL, *inTail = NULL;
inline char Getchar()
{
if(inHead == inTail)
inTail=(inHead=inBuffer)+fread(inBuffer, 1, inBufferSize, stdin);
return *inHead++;
}
}
#define getchar() IN::Getchar()
template <typename T>
inline void scan_ud(T &ret)
{
char c = getchar();
ret = 0;
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9')
ret = ret * 10 + (c - '0'), c = getchar();
}
scan_ud(t);
版本2
- struct FastIO
- {
- static const int S = 2*100;
- 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 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;
- }
- ~FastIO()
- {
- if(wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
- }
- }io;
- n = io.xint();
版本三(含强力输出)
原理是将数据一次性全部读入到内存中。
适用于正负int / LL / double 的.
template <class T>
bool scan_d(T &ret)
{
char c;
int sgn;
T bit=0.1;
if(c=getchar(), c==EOF)
return 0;
while(c!='-' && c!='.' && (c<'0' || c>'9'))
c=getchar();
sgn=(c=='-')? -1:1;
ret=(c=='-')? 0:(c-'0');
while(c=getchar(), c>='0' && c<='9')
ret=ret*10+(c-'0');
if(c==' ' || c=='\n')
{
ret*=sgn;
return 1;
}
while(c=getchar(), c>='0' && c<='9')
ret+=(c-'0')*bit, bit/=10;
ret*=sgn;
return 1;
}