Educational Codeforces Round 65 (Rated for Div. 2) A. Telephone Number
链接: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的更多相关文章
- Educational Codeforces Round 65 (Rated for Div. 2)题解
Educational Codeforces Round 65 (Rated for Div. 2)题解 题目链接 A. Telephone Number 水题,代码如下: Code #include ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- [ 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 ...
- Educational Codeforces Round 65 (Rated for Div. 2)
A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 ...
- Educational Codeforces Round 65 (Rated for Div. 2) E. Range Deleting(思维+coding)
传送门 参考资料: [1]:https://blog.csdn.net/weixin_43262291/article/details/90271693 题意: 给你一个包含 n 个数的序列 a,并且 ...
- 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 ...
随机推荐
- iOS Assertion failure in -[UITableView _classicHeightForRowAtIndexPath:]
Assertion failure in -[UITableView _classicHeightForRowAtIndexPath:], /SourceCache/UIKit_Sim/UIKit-3 ...
- Jmeter-JDBC Request
1. 新建一个测试计划 2. 新建一个线程组 3. 创建数据库连接 4.配置数据库连接 5.添加JDBC Request 6.添加监听器
- ICE 迁移64位安装问题
昨天手贱,在apt-get install 后有一大堆,上百个安装包not upgrade, 发现有提示apt-get autoremove,犹豫了很久后还是忍不住执行了autoremove:这个命令 ...
- bootstrap框架日期时间 开始日期和结束日期选择
页面表单查询时,常要求要查询一个日期时间段内的数据,若采用bootstrap框架的datetimepicker插件来控制,需要了解怎么个用法:
- java面试题07
1.重载和重写的区别? 重载(Overload):(1)方法重载是让类以统一的方式处理不同类型数据的一种手段.多个同名函数同时存在,具有不同的参数个数/类型.重载Overloading是一个类中多态性 ...
- ACM学习历程——UVA442 Matrix Chain Multiplication(栈)
Description Matrix Chain Multiplication Matrix Chain Multiplication Suppose you have to evaluate ...
- 【Lintcode】104.Merge k Sorted Lists
题目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexit ...
- MSTAR 平台
MApp_Menu.c ZUI_exefunc.h //菜单属性 MApp_ZUI_APItables.h #define GETWNDINFO(hwnd) (&g_GUI_WindowLis ...
- JavaScript总结(1)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- C#防止sql注入
public class SqlZr { public SqlZr() { // // TODO: 在此处添加构造函数逻辑 / ...