Educational Codeforces Round 63 (Rated for Div. 2) B题

题目网址:https://codeforc.es/contest/1155/problem/B

题目大意:有两个人A,B博弈,在一串数字中,A先取数,B后取数,最后剩11个数的时候停止,如果第一个数是8,则A胜,反之B胜

题解:取数到最后,只剩11个数,且,A如果要赢,第一个数是8,则A显然是要尽可能的先取前面的非8数,B要先去前面的8,按照这样的策略,只需考虑前面n -10个数取到最后是否有8即可,显然是判断8的数量和其他数的数量的大小即可。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 const int maxn=3e5+7;
 4 char s[maxn];
 5 int main()
 6 {
 7     int n,tot=0;
 8     cin>>n;
 9     scanf("%s",s+1);
10     for(int i=1;i<=n-10;i++) {
11         if(s[i]==‘8‘) tot++;
12         else tot--;
13     }
14     if(tot>0) printf("YES");
15     else printf("NO\n");
16     return 0;
17 } 

原文地址:https://www.cnblogs.com/duxing201806/p/10805526.html

时间: 2024-07-31 09:43:16

Educational Codeforces Round 63 (Rated for Div. 2) B题的相关文章

Educational Codeforces Round 63 (Rated for Div. 2) D题

题目网址:https://codeforc.es/contest/1155/problem/D 题目大意:给定n个数和一个k,可以对这n个数进行一次操作,也可以不进行,即选择某个区间中的数都乘上k,问最后最大连续子段和是多少? 题解:(鶸鶸的我是看别人的博客才解决的 ! ) 首先这道题的状态很多,对于前m个数,乘k之前的状态,乘k的状态,之和的状态都需要建立.那么分别设dp1,dp2,dp3是乘k之前,乘k时,乘k之和,前m个数最大连续子段和. 首先对于dp1,即一组数的最大子段和,显然只要是正

Educational Codeforces Round 74 (Rated for Div. 2)补题

慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ? ? //√,×,? 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x>y)\),问能否将\(x-y\)拆成任意多个质数之和 1.任意大于\(1\)的整数\(k\)都可以用\(2\)与\(3\)的线性表示 证: 若\(k\)是偶数,显然: 若\(k\)是奇数,则\(k\)可以表示成\(k = 3 + 2*k'\),显然: 毕. #include<bits/stdc++.h&

codeforces Educational Codeforces Round 55 (Rated for Div. 2) C题 C. Multi-Subject Competition

这道题比赛时候没做出来,下来一看才发现是排序傻逼题. 把每个偏好的人做成一个vector,从大到小排序,做一个前缀和.然后将每种人数做一个桶,在桶里装每种科目选择人数为i的时候分数总和. 遍历每一维vector,把各个位置上面的vector加到sum数组中,最后sum数组里面挑出最大值. #include<bits/stdc++.h> using namespace std; typedef long long ll; vector<int> vec[100010];//vecto

Educational Codeforces Round 33 (Rated for Div. 2) A题

A. Chess For Three Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game fo

Educational Codeforces Round 33 (Rated for Div. 2) B题

B. Beautiful Divisors Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes. Some example

Educational Codeforces Round 33 (Rated for Div. 2) C题&#183;(并查集变式)

C. Rumor Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it

Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】

B. The Modcrab Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab. After two hours of playing the game Vova has tracked the monster and analyzed its tactics

Educational Codeforces Round 78 (Rated for Div. 2) --补题

链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = {0}; int judge() { //cout<<"111"<<endl; for (int i = 0; i < 26; ++i) { if (a[i]!=b[i]) { return 0; } } return 1; } int main() { //

Educational Codeforces Round 57 (Rated for Div. 2)

get人生第二场CF! 成绩:(exACM) rank858 AC3/7 Penalty57 rating1648(+52) 题目:Educational Codeforces Round 57 (Rated for Div. 2) 错题题解: D. Easy Problem E. The Top Scorer F. Inversion Expectation G. Lucky Tickets 原文地址:https://www.cnblogs.com/xht37/p/10198321.html