快读模板

快读模板

CF4A Watermelon为例
Code:

#include<bits/stdc++.h>
using namespace std;
int n;
inline int read()//快读模板
{
    int s = 0,w = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')w = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
int main()
{
    n = read();
    if(n == 2)printf("NO");
    if(n % 2)printf("NO");
    else printf("YES");
    return 0;
}

将快读单独提取:

inline int read()
{
    int s = 0,w = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')w = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
posted @ 2020-02-16 17:25  zzx0826  阅读(158)  评论(0编辑  收藏  举报