Educational Codeforces Round 65 (Rated for Div. 2)A. Telephone Number
题目来源:https://codeforces.com/contest/1167/problem/A
题意:给你一个数字串问你能不能从中截取一个以8开头的长为11的电话号码。
思路:遍历0到n-11看有没有存在8.存在即可。
参考代码:
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define PII pair<int,int>
#define PB push_back
#define POP pop_back
#define FI first
#define SE second
#define endl '\n'
#define ls x<<1
#define rs x<<1|1
const int N=3e6+7,mod=1e9+7,INF=1e9;
int main() {
int t,n;
cin>>t;
while(t--){
cin>>n;
string s;
cin>>s;
bool falg=0;
for(int i=0;i<=n-11;i++){
if(s[i]=='8'){
falg=1;
break;
}
}
if(falg)
cout <<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}