zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 63 (Rated for Div. 2) B. Game with Telephone Numbers 博弈思维+模拟+贪心思维

    题意:博弈题面  给出一个数字序列 (>=11)  有两个人任意删除数字 直到 数字只剩下11位 如果删除后的数字串开头是8那么就是第一个赢 否则就是第二个人赢

    第一个人先手  数字序列一定是奇数长度

    思路: 首先计算一共走多少步 

    第二个人想赢只有以下两种方法

    想法1:如果第二个人能把8都删掉 那么第二个人肯定赢

    想法2: 如果删不掉 那么第二个人肯定从前到后尽可能得删掉8 这样使得第一个人的步数不足删除从前到后 步数+1那个8 的其他字符

    否则就是第一人赢,直接模拟即可  

    (比赛的时候一直WA 不知道为什么 然后果断重写了一遍才pp(并且没有fft 2333)) 所以重写大法好

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 const int maxn=3e5+5;
     5 char s[maxn];
     6 int main(){
     7     int n;
     8     scanf("%d",&n);
     9     scanf("%s",s+1);
    10     int cnt=0;
    11     int huihe=n-11;
    12     for(int i=1;i<=n;i++){
    13         if(s[i]=='8')cnt++;
    14     }
    15     int flag=0;
    16     int i;
    17     for( i=1;i<=n;i++){
    18         if(s[i]=='8')flag++;
    19         if(flag==huihe/2+1)break;
    20     }
    21     if(cnt<=huihe/2){
    22         cout<<"NO
    ";
    23     }
    24     else {
    25         if((i-1-huihe/2)<=huihe/2)cout<<"YES
    ";
    26         else cout<<"NO
    ";
    27     }
    28     return 0;
    29 }
    View Code
  • 相关阅读:
    [CF1051F] The Shortest Statement
    [国家集训队] 墨墨的等式
    [CF558E] A Simple Task
    [洛谷P1349] 广义斐波那契数列
    [TJOI2009] 猜数字
    [洛谷P3403] 跳楼机
    学习力
    启动流程
    《鸟哥Linux》笔记——磁盘分区
    indexDB数据库
  • 原文地址:https://www.cnblogs.com/ttttttttrx/p/10791308.html
Copyright © 2011-2022 走看看