题目链接:http://www.codeforces.com/problemset/problem/96/A
题意:判断一个0-1字符串中出现的最长的0字串或者1字串的长度是否大于等于7。
C++代码:
#include <cstdio> #include <iostream> #include <string> using namespace std; string s; int tmp = 1; bool chk() { int len = s.length(); for (int i = 1; i < len; i ++) if (s[i] == s[i-1]) { tmp ++; if (tmp >= 7) return true; } else tmp = 1; return false; } int main() { cin >> s; puts(chk() ? "YES" : "NO"); return 0; }