forked from MyK00L/fastio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfastio.c
78 lines (63 loc) · 1.27 KB
/
fastio.c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <unistd.h>
//#include <stdio.h>
#define NBIN 8000000
#define NBOUT 20
unsigned char input[NBIN];
unsigned inputi;
unsigned char output[NBOUT];
unsigned outputi;
//if values are already 0, you can delete first line
#define get_uns(x){\
x=0;\
while(input[inputi]<=32)inputi++;\
while(input[inputi]>32)x=x*10+input[inputi++]-'0';\
}
#define get_int(x){\
x=0;\
unsigned char sign=0;\
while(input[inputi]<=32)inputi++;\
if(input[inputi]=='-'){sign=1;inputi++;}\
while(input[inputi]>='0')x=x*10+input[inputi++]-'0';\
if(sign)x=-x;\
}
#define get_char(x){\
x=input[inputi++];\
}
//can't print 0, modifies value (thus x has to be lvalue)
#define put_uns(x){\
unsigned char _put_b[22];\
char _put_t=0;\
while(x){\
_put_b[_put_t++]=x%10+'0';\
x/=10;\
}\
while(--_put_t>=0)output[outputi++]=_put_b[_put_t];\
}
#define put_int(x){\
if(x<0){\
output[outputi++]='-';\
x=-x\
}\
put_uns(x)\
}
#define put_char(x){\
output[outputi++]=x;\
}
void put_str(char *x){
while(*x)output[outputi++]=*(x++);
}
int main(){
read(0,input,NBIN);
//fread_unlocked(input,1,NBIN,stdin);
unsigned x;
get_uns(x);
if(x==0)put_str("x=0\n");
else {
put_str("x=");
put_uns(x);
put_char('\n');
}
write(1,output,outputi);
//fwrite_unlocked(output,1,outputi,stdout);
return 0;
}