IO

读优输优

fread

1
2
3
4
5
6
7
8
9
10
const int L=1000000;
char *p1,*p2,ppp[L];
inline char gc()
{
if(p1==p2)
{
p2=(p1=ppp)+fread(ppp,1,L,stdin);
}
return *p1++;
}

读优输优

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void read(int &x)
{
x=0;
char ch=getchar();
int pd=1;
while(ch<'0'||ch>'9')
{
if(ch=='-')
{
pd=-pd;
}
ch=getchar();
}
while(ch<='9'&&ch>='0')
{
x=x*10+ch-'0';
ch=getchar();
}
x*=pd;
}
void write(const int &x)
{
char f[100001];
int s=0;
int tmp=x;
if(tmp==0)
{
putchar('0');
return;
}
if(tmp<0)
{
tmp=-tmp;
putchar('-');
}
while(tmp>0)
{
f[s++]=tmp%10+'0';
tmp/=10;
}
while(s>0)
{
putchar(f[--s]);
}
}