题意描述
规定电话号码是以8开头的11位数字。现在给你一串数字,每人可以选择移除一个数字,问最后是否可以构成电话号码
思路
通过观察发现,对手每次删除都要删除靠前的位置,所以我们判断前n-10位,如果其他数字的个数比8多,则不能胜利,否则就可以达成目标。
代码
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef pair<char,char> PCC;
typedef long long LL;
const int N=105;
const int M=150;
const int INF=0x3f3f3f3f;
const int MOD=998244353;
int a[N];
void solve(){
int n;cin>>n;
string s;cin>>s;
int cnt1=0,cnt2=0;
for(int i=0;i<n-10;i++){
if(s[i]=='8') cnt1++;
else cnt2++;
}
cnt1 > cnt2 ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}
int main(){
IOS;
solve();
return 0;
}