Educational Codeforces Round 65 (Rated for Div. 2)

题目大意:给定你t个长度为N的字符串,问你能否通过删除字符串得到长度为11位且首位位8的电话号码。

思路:若N<11直接输出NO,N>=11 则枚举前 0  - (N-11)位,若其中有8出现则输出YES,否则是NO。

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstring>
 4 #include<cstdio>
 5 #include<queue>
 6 #include<vector>
 7 #include<cmath>
 8 #include<map>
 9 #include<set>
10 using namespace std;
11 typedef long long LL;
12 const int maxn = 1e5+10;
13 LL n,t;
14 string str;
15 int main()
16 {
17     cin>>t;
18     while(t--){
19         cin>>n;
20         cin>>str;
21         string ans = "NO";
22         for(int i=0;i<n-10;i++){
23             if(str[i]=='8'){
24                 ans = "YES";
25                 break;
26             }
27         }
28         cout<<ans<<endl;
29     }
30     return 0;
31 }
View Code

相关文章: