banner
NEWS LETTER

快读快写 | OI笔记

Scroll down

快读快写模板

普通简版

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
#include<iostream>
#include<cctype>

using namespace std;

template <typename T>
inline void input(T &x)
{
x = 0; char c = getchar();
for(; !isdigit(c); )
c = getchar();
for(; isdigit(c); c = getchar())
x = x * 10 + (c ^ '0');
}

template <typename T>
inline void output(T x, char ed = '\n')
{
static short st[30], idx;
do st[++ idx] = x % 10, x /= 10; while(x);
while(idx) putchar(st[idx --] | '0');
putchar(ed);
}

int main()
{
int a,b;
input(a);
input(b);
cout << a << endl << b << endl;
output(a + b);
return 0;
}

终版

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
#include<iostream>
#include<cstdio>

#ifdef __LINUX__
#define getchar() getchar_unlocked()
#define putchar(a) putchar_unlocked(a)
#endif

#ifdef __WINDOWS__
#define getchar() _getchar_nolock()
#define putchar(a) _putchar_nolock()
#endif

using namespace std;

template <typename T> void input(T &x)
{
x = 0; char c = getchar(); bool f = false;
while (c < '0' or c > '9')
f |= (c == '-'), c = getchar();
while (c >= '0' and c <= '9')
x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
x = f ? -x : x;
}

template <typename T, typename... Args>
void input(T &x, Args&... args)
{
input(x), input(args...);
}

template <typename T>
void output(T x, char ed = ' ')
{
if (x < 0) putchar('-'), x = -x;
static short st[64], top;
top = 0;
do st[top ++] = x % 10, x /= 10; while (x);
while (top --) putchar(st[top] ^ '0');
putchar(ed);
}
template <typename T, typename ...Args>
void output(T x, char ch = ' ', Args... args) {
output(x, ch);
output(args...);
}

int main()
{
int a, b, c;
input(a, b, c);
output(a, ' ', b, ' ', c, ' ');
return 0;
}
Other Articles
cover
可持久化数据结构 | OI笔记
  • 23/03/02
  • 10:06
  • 信息竞赛
Please enter keywords to search