題意描述
規定電話號碼是以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;
}