6486: An Ordinary Game(规律)
题目描述
Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:
Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s.
The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
Constraints
3≤|s|≤105
s consists of lowercase English letters.
No two neighboring characters in s are equal.
输入
s
输出
样例输入
aba
样例输出
Second
提示
Takahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of s, would result in s becoming aa, with two as neighboring.
很很简单的一个找规律题,但是卡了好久。
头尾相同的时候,最后肯定是剩下奇数个字母的,比如ababa。那么如果位数是奇数那么中间肯定进行了偶数次操作,反正就是奇数次。
头尾不同的话,最后剩下偶数个,如果位数为奇数就操作了奇数次,否则偶数次。
偶数次操作那么第一个人就无法操作就输,奇数次操作第二个人无法操作即输。
#include<bits/stdc++.h>
using namespace std; int main()
{
string s;
cin>>s;
int len = s.length();
if(s[] == s[len-])
if(len&)printf("Second\n");
else printf("First\n");
else
if(len&)printf("First\n");
else printf("Second\n");
}
6486: An Ordinary Game(规律)的更多相关文章
- Flower(规律+逆向思维)
Flower: 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6486 题解: 逆向思维+规律 因为每次剪n-1,所以逆向就是控制n-1朵不变,每次增高1 ...
- hdu1452 Happy 2004(规律+因子和+积性函数)
Happy 2004 题意:s为2004^x的因子和,求s%29. (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...
- Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)
传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...
- ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)
//POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...
- HDU 5795 A Simple Nim 打表求SG函数的规律
A Simple Nim Problem Description Two players take turns picking candies from n heaps,the player wh ...
- 在sqlserver中做fibonacci(斐波那契)规律运算
--利用sqlserver来运算斐波那契规律 --利用事物与存储过程 declare @number intdeclare @A intdeclare @B intdeclare @C int set ...
- 谈谈黑客攻防技术的成长规律(aullik5)
黑莓末路 昨晚听FM里谈到了RIM这家公司,有分析师认为它需要很悲催的裁员90%,才能保证活下去.这是一个意料之中,但又有点兔死狐悲的消息.可能在不久的将来,RIM这家公司就会走到尽头,或被收购,或申 ...
- Math.abs(~2018),掌握规律即可!
Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...
- COM中需要调用AddRef和Release的10条规律
COM中需要调用AddRef和Release的10条规律
随机推荐
- js——事件冒泡与捕获小例子
布局代码 #outer{ width: 300px; height: 300px; background: red; } #inner{ width: 200px; height: 200px; ba ...
- Confluence 6 附件存储选项
在早期的 Confluence 版本中,我们允许存储附件到 WebDav 或者 Confluence 数据库中.针对新的 Confluence 安装,我们不再支持这 2 种存储了. 本地文件系统 在默 ...
- (六)STL仿函数functor
1.仿函数为算法服务,特点是重载操作符() 2.一共分为3大类,包括算术类,逻辑运算类,相对关系(比较大小):都继承了binary_function 3.仿函数的一些调用示例,其中右边的仿函数没有继承 ...
- SpringMVC视图及REST风格
点击进入第二章:SpringMVC基础配置 什么是视图解析器? springMVC用于处理视图最重要的两个接口是ViewResolver和View. ViewResolver的主要作用是把一个逻辑上的 ...
- PDF文件编辑技巧之PDF书签怎么设置
纸质的文件想要添加书签就直接拿笔书写就可以,Word文件怎么添加书签相信大家也都知道,那么PDF文件的书签要怎么设置的呢,是不是有很多小伙伴不知道该怎么做呢,不要担心,今天小编就来跟大家分享一下在PD ...
- Brup Suite 渗透测试笔记(七)
继续接上次笔记: 1.Burp Intruder的payload类型的子模块(Character blocks)使用一种给出的输入字符,根据指定的设置产生指定大小的字符块,表现形式为生成指定长度的字符 ...
- 高斯消元-poj1222熄灯问题状态压缩解法
有点自闭的..为什么我最后的答案是倒着来的啊.. 搞明白了:因为一开始构造的系数就是反着的,,所以主元也倒过来了.. #include<iostream> #include<cstd ...
- Android Studio 设置编辑器(Editor)的字体、字体大小
操作系统:Windows 10 x64 IDE:Android Studio 3.2.1 参考:https://www.cnblogs.com/diyishijian/p/6824328.html 备 ...
- Leetcode刷题第001天
一.合并两个有序链表 [题目]206. 反转链表 /** * Definition for singly-linked list. * struct ListNode { * int val; * L ...
- 一脸懵逼学习Hive的元数据库Mysql方式安装配置
1:要想学习Hive必须将Hadoop启动起来,因为Hive本身没有自己的数据管理功能,全是依赖外部系统,包括分析也是依赖MapReduce: 2:七个节点跑HA集群模式的: 第一步:必须先将Zook ...