【CodeForces】696A - Football(连续子串,水)
来源:互联网 发布:淘宝怎么删除下架宝贝 编辑:程序博客网 时间:2024/05/21 15:38
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.
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.
Print "YES" if the situation is dangerous. Otherwise, print "NO".
001001
NO
1000000001
YES
水题for循环滚过去就行了。
代码如下:
#include <cstdio>#include <cstring>int main(){char a[111];int l;bool flag;while (~scanf ("%s",a)){flag = false;l = strlen (a);if (l < 7){printf ("NO\n");continue;}for (int i = 0 ; i < l-6 ; i++){if (flag)//如果发现成立,立马退出 break;if (a[i+1] == a[i]){int num = 1;for (int j = i + 1 ; j < l ; j++){if (a[j] == a[j-1])num++;elsebreak;if (num == 7){flag = true;break;}}}}if (flag)printf ("YES\n");elseprintf ("NO\n");}return 0;}
- 【CodeForces】696A - Football(连续子串,水)
- CodeForces 96 A.Football(水~)
- Codeforces 493A. Vasya and Football 水
- Codeforces 493A Vasya and Football(水)
- Codeforces 96A: Football(水题)
- CodeForces-96A-Football
- Codeforces 43 A. Football
- 【CodeForces】A. Football
- CodeForces 96A Football
- codeforces 43A Football
- codeforces 96A Football
- Problem--96A--Codeforces--Football
- CodeForces 19A World Football Cup (水题)
- codeforces 781B. Innokenty and a Football League(贪心)
- codeforces 788 A. Functions again(最大连续子序列和)
- Codeforces 19A World Football Cup 【模拟】
- CodeForces 19A World Football Cup
- CodeForces-493A.Vasya and Football
- Shader Forge初级篇|RGB通道的UV混合效果 一
- mysq集群原理之Galera replication
- POJ 3744 Scout YYF I 矩阵快速幂+概率dp
- 无序列表<ul>与列表项目<li>
- OS X git之 Probably the path to Git executable is not valid
- 【CodeForces】696A - Football(连续子串,水)
- iPhone实现自定义多选列表
- UNIX网络编程之管道
- 关于Nim博弈的一点小理解----谁才是最强战舰
- H.264中的SPS、PPS提取与作用
- http状态码301与302的区别
- 【剑指offer】两队列实现栈与两栈实现队列
- 图解Oracle 12c 手动建库
- libpng库的安装与使用(交叉编译)