codeforces689A

div2A

用四个二进制位记每个点状态,O(n)判断一下即可

codeforces689A
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
    ll s=0; bool f=0; char ch=' ';
    while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
    while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0) {putchar('-'); x=-x;}
    if(x<10) {putchar(x+'0'); return;}
    write(x/10); putchar((x%10)+'0');
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=10;
int n,b[N];
int main()
{
    freopen("codeforces.in","r",stdin);
    int i,wwx=15;
    char ch=' ';
    R(n);
    b[0]=1;
    b[1]=6;
    b[2]=14;
    b[3]=12;
    b[4]=7;
    b[5]=15;
    b[6]=13;
    b[7]=3;
    b[8]=15;
    b[9]=9;
    for(i=1;i<=n;i++)
    {
        while(!isdigit(ch)) ch=getchar();
        wwx&=b[(int)ch-'0'];
        ch=' ';
    }
    wwx?puts("NO"):puts("YES");
    return 0;
}
View Code

 

上一篇:网络相关命令收集


下一篇:分享一两个小工具,