链接:https://codeforces.com/contest/1167/problem/A

题意:

A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388and 80000011223388 are not.

You are given a string ss of length nn, consisting of digits.

In one operation you can delete any character from string ss. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.

You need to determine whether there is such a sequence of operations (possibly empty), after which the string ss becomes a telephone number.

思路:

找到第一个8出现的位置。再把多余的减掉看是否符合。

代码:

#include <bits/stdc++.h>
using namespace std; typedef long long LL;
const int MAXN = 1e5+10; int main()
{
int t;
cin >> t;
while (t--)
{
int n;
string s;
cin >> n >> s;
int cnt = -1;
for (int i = 0;i < s.length();i++)
{
if (s[i] == '8')
{
cnt = i;
break;
}
}
if (cnt == -1)
cout << "NO" << endl;
else if (s.length() - cnt < 11)
cout << "NO" << endl;
else
cout << "YES" << endl;
} return 0;
}

  

最新文章

  1. hashCode的作用
  2. Form onsubmit 事件 阻止表单提交() 必须选中同意选项才可以提交
  3. mybatis实战教程(mybatis in action)之四:实现关联数据的查询
  4. Junit单元测试笔记
  5. ASP.NET Core学习零散记录
  6. Vmware虚拟机
  7. ADF_General JSF系列1_创建一个简单的JSF Application
  8. C++_快速排序
  9. 数据结构——N皇后放置方法种数
  10. HTML5 Canvas图像放大、移动实例1
  11. 与redmine对接
  12. 使用dns批量管理普通主机名相关问题
  13. 链表底层实现Java的Map(上)
  14. spring boot junit controller
  15. 电话号自动识别之bug解决汇总
  16. Ubuntu16.04下通过tar.gz包安装MySQL5.5.52
  17. yolo源码解析(一)
  18. 高性能mysql 第1,2,3章。
  19. [py]django强悍的数据库接口(QuerySet API)-增删改查
  20. socket 请求接收完整的一个http响应(设置recv 接收超时选项SO_RCVTIMEO)

热门文章

  1. html5--2.4新的布局元素(3)-section
  2. Linux下查看端口占用情况
  3. tensorflow 实现逻辑回归——原以为TensorFlow不擅长做线性回归或者逻辑回归,原来是这么简单哇!
  4. Go丨语言学习笔记--switch
  5. L87
  6. [acm]HDOJ 2059 龟兔赛跑
  7. COGS 2581 无聊的会议V2
  8. iview之select选择框选中内容后有空格的问题
  9. iView之select获取value和label
  10. python中出现 IndentationError:unindent does not match any outer indentation level