zoukankan      html  css  js  c++  java
  • codeforces982A

    题意 

    给你个排列    10001

    满足下列条件输出yes  否则输出no

    1、不能有两个1相连

    2、当点排列不能再加入1

    全0判断一下

    开头判断一下

    结尾判断一下

    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    char str[1005];
    int main()
    {
        int n,i,pre,cnt = 0;
        bool flag = false;
        scanf("%d",&n);
        scanf("%s",str);
        if(n == 1)
        {
            if(str[0] == '1')
                printf("Yes
    ");
            else
                printf("No
    ");
            return 0;
        }
        pre = -2;
        if(str[0] == '1')
        {
            pre = 0;
            flag = true;
        }
        for(i=1;i<strlen(str);++i)
        {
            if(str[i] == '1')
            {
                flag = true;
                if((i-pre!=2) && (i-pre!=3))
                {
                    printf("No
    ");
                    return 0;
                }
                pre = i;
            }
        }
        i--;
        if(str[i] == '0')
        {
            if(i - pre == 2 || i-pre == 3)
                flag = false;
        }
        if(flag)
            printf("Yes
    ");
        else
            printf("No
    ");
    }
  • 相关阅读:
    settTimeout vs setInterval
    JS继承
    JS创建对象
    原型链
    开始学习python的感受
    Problem 29
    Python 查看关键字
    Problem 21
    Problem 34
    Problem 42
  • 原文地址:https://www.cnblogs.com/mltang/p/9066152.html
Copyright © 2011-2022 走看看