链接: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;
}

  

Educational Codeforces Round 65 (Rated for Div. 2) A. Telephone Number的更多相关文章

  1. Educational Codeforces Round 65 (Rated for Div. 2)题解

    Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...

  2. Educational Codeforces Round 65 (Rated for Div. 2) D. Bicolored RBS

    链接:https://codeforces.com/contest/1167/problem/D 题意: A string is called bracket sequence if it does ...

  3. Educational Codeforces Round 65 (Rated for Div. 2) C. News Distribution

    链接:https://codeforces.com/contest/1167/problem/C 题意: In some social network, there are nn users comm ...

  4. Educational Codeforces Round 65 (Rated for Div. 2) B. Lost Numbers

    链接:https://codeforces.com/contest/1167/problem/B 题意: This is an interactive problem. Remember to flu ...

  5. Educational Codeforces Round 65 (Rated for Div. 2)B. Lost Numbers(交互)

    This is an interactive problem. Remember to flush your output while communicating with the testing p ...

  6. [ Educational Codeforces Round 65 (Rated for Div. 2)][二分]

    https://codeforc.es/contest/1167/problem/E E. Range Deleting time limit per test 2 seconds memory li ...

  7. Educational Codeforces Round 65 (Rated for Div. 2)

    A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...

  8. Educational Codeforces Round 65 (Rated for Div. 2) E. Range Deleting(思维+coding)

    传送门 参考资料: [1]:https://blog.csdn.net/weixin_43262291/article/details/90271693 题意: 给你一个包含 n 个数的序列 a,并且 ...

  9. Educational Codeforces Round 65 (Rated for Div. 2)(ACD)B是交互题,不怎么会

    A. Telephone Number A telephone number is a sequence of exactly 11 digits, where the first digit is  ...

随机推荐

  1. JAVA-三大语句(选择语句、条件语句、循环语句)

    跳出指定的for循环体,和goto很像 1 K:for(int i=0;i<3;i++){//给这个for循环体取一个名字为K 2 for(int j=0;j<3;j++){ 3 if(j ...

  2. c++的最小整数和最大整数

    #include<iostream> #include<cmath> using namespace std; int main() { //int -2147483648~2 ...

  3. BZOJ 2021 [Usaco2010 Jan]Cheese Towers:dp + 贪心

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2021 题意: John要建一个奶酪塔,高度最大为m. 他有n种奶酪.第i种高度为h[i]( ...

  4. 相对路径转绝对路径C++实现

    #include<iostream> #include<string> #include<vector> using namespace std; //相对路径转绝 ...

  5. Redis实现求交集操作结果缓存的设计方案

    Redis的集合操作 实话说,Redis提供的集合操作是我选择它成为内存数据库的一个主要理由,它弥补了传统关系型数据库在这方面带来的复杂度,使得只需要简单的一个命令就可以完成一个复杂SQL任务,并且交 ...

  6. SQL大全(1)

    实用SQL语句大全 一.基础 1.创建数据库 create database 数据库名 2.删除数据库 drop database 数据库名 3.增加列 alter table 表名 add 列名 类 ...

  7. cnblogs开源合集

    http://www.cnblogs.com/davytitan/p/4135151.html

  8. [xdoj1233]Glory and LCS

    题意:求两个排列的最长公共子序列n<=1e5 解题关键:转化为LIS. 最长公共子序列 的 nlogn 的算法本质是 将该问题转化成 最长增序列(LIS),因为 LIS 可以用nlogn实现,所 ...

  9. pysam操作sam文件

    pysam模块 因为要分析sam文件中序列的情况,因此要对reads进行细分,所以之前想用数据库将sam文件信息存储,然后用sql语句进行分类.后来发现很麻烦,pysam就是一个高效读取存储在SAM ...

  10. 滴滴Booster移动APP质量优化框架 学习之旅

    推荐阅读: 滴滴Booster移动App质量优化框架-学习之旅 一 Android 模块Api化演练 不一样视角的Glide剖析(一) 一.Booster简介 Booster是滴滴最近开源一个的移动应 ...