zoukankan      html  css  js  c++  java
  • A. Football

    Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If there are at least 7 players of some team standing one after another, then the situation is considered dangerous. For example, the situation 00100110111111101 is dangerous and 11110111011101 is not. You are given the current situation. Determine whether it is dangerous or not.

    Input

    The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field.

    Output

    Print "YES" if the situation is dangerous. Otherwise, print "NO".

    Examples
    input
    001001
    output
    NO
    input
    1000000001
    output
    YES

     1 #include <stdio.h>
     2 #include <string.h>
     3 using namespace std;
     4 int main(){
     5     char s[105];
     6     scanf("%s",s);
     7     if(strstr(s,"1111111")||strstr(s,"0000000")) printf("YES");
     8     else printf("NO");
     9     return 0;
    10 }
    或者

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 using namespace std;
     5 int main(){
     6     int n,j=0;
     7     char str[120];
     8     scanf("%s",str);
     9     n=strlen(str);
    10     for(int i=0;i<n-5;i++){
    11         if((str[i]==str[i+1])&&(str[i+1]==str[i+2])&&(str[i+2]==str[i+3])&&(str[i+3]==str[i+4])&&(str[i+3]==str[i+4])&&(str[i+4]==str[i+5])&&(str[i+5]==str[i+6]))
    12             j=1;
    13     }
    14     if(j==1) printf("YES
    ");
    15     else printf("NO
    ");
    16     return 0;
    17 }
    
    
    
     
  • 相关阅读:
    video 安卓ios系统 浏览器 全屏播放以及自动播放的问题
    echarts 雷达图的个性化设置
    AtCoder Grand Contest 015 题解
    AtCoder Grand Contest 014 题解
    bzoj 3242: [Noi2013]快餐店
    bzoj 2794: Cloakroom dp
    bzoj 4261: 建设游乐场 费用流
    uoj problem 31 猪猪侠再战括号序列
    APIO2017 游记
    CTSC2017 游记
  • 原文地址:https://www.cnblogs.com/z-712/p/7307395.html
Copyright © 2011-2022 走看看