题目描述

There is a string s of length 3 or greater. No two neighboring characters in s are equal.
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.

输入

The input is given from Standard Input in the following format:
s

输出

If Takahashi will win, print First. If Aoki will win, print Second.

样例输入

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(规律)的更多相关文章

  1. Flower(规律+逆向思维)

    Flower: 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6486 题解: 逆向思维+规律 因为每次剪n-1,所以逆向就是控制n-1朵不变,每次增高1 ...

  2. hdu1452 Happy 2004(规律+因子和+积性函数)

    Happy 2004 题意:s为2004^x的因子和,求s%29.     (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...

  3. 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 ...

  4. ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)

    //POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...

  5. HDU 5795 A Simple Nim 打表求SG函数的规律

    A Simple Nim Problem Description   Two players take turns picking candies from n heaps,the player wh ...

  6. 在sqlserver中做fibonacci(斐波那契)规律运算

    --利用sqlserver来运算斐波那契规律 --利用事物与存储过程 declare @number intdeclare @A intdeclare @B intdeclare @C int set ...

  7. 谈谈黑客攻防技术的成长规律(aullik5)

    黑莓末路 昨晚听FM里谈到了RIM这家公司,有分析师认为它需要很悲催的裁员90%,才能保证活下去.这是一个意料之中,但又有点兔死狐悲的消息.可能在不久的将来,RIM这家公司就会走到尽头,或被收购,或申 ...

  8. Math.abs(~2018),掌握规律即可!

    Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...

  9. COM中需要调用AddRef和Release的10条规律

    COM中需要调用AddRef和Release的10条规律  

随机推荐

  1. winform里面打开网页(转)

    首先,新建一个winform项目,我在想,如果想要实现打开网页功能的话,应该会有一个控件什么之类的吧?查了工具栏,真的有一个名叫 WebBrowser的家伙,应该就是这货没错了.在网上查了它的资料更加 ...

  2. 神经网络之dropout层

    一:引言 因为在机器学习的一些模型中,如果模型的参数太多,而训练样本又太少的话,这样训练出来的模型很容易产生过拟合现象.在训练bp网络时经常遇到的一个问题,过拟合指的是模型在训练数据上损失函数比较小, ...

  3. vue 循环前十条数据

    v-for="(item, index) in items" v-if="index<10"

  4. 【python】mongo删除数据

    参考:https://stackoverflow.com/questions/23334743/setting-justone-limiter-for-pymongo-remove-throws-ty ...

  5. javaSocket笔记

    1.查看电脑当前开放链接的端口号 使用netstat命令 netstat -nao 可以查看PID进程号 netstat -nab 获取进程的详细信息 2.类创建的不同对象,引用是不同的.也就是说同一 ...

  6. linux下搭建SVN

      官网下载: http://subversion.apache.org/packages.html SVN客户端:TortoiseSVN :https://tortoisesvn.net/downl ...

  7. animate方法使用总结

    <!DOCTYPE html><html lang="en" class="loading"><head> <meta ...

  8. ActiveSync的Settings命令

           在[MS-ASCMD]中,Settings命令的功能这样定义的:        The Settings command also sends device information to ...

  9. 给servlet类添加源代码

    1.按住ctrl键不放.鼠标左键点击HttpServlet. 2.打开 https://mvnrepository.com/下载所需的jar包,要下载带-sources后缀的 3.点击按钮附加源代码 ...

  10. 字符转ASCII码

    char k = '成'; int str = (int)k; Console.WriteLine(str); 结果25104就是‘成’对应的ASCII值