题目描述

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. Confluence 6 通过 SSL 或 HTTPS 运行

    Atlassian 应用可以通过 HTTPS 进行访问,但是 Atlassian 并不提供有关访问的支持服务,同时 Atlassian 不能保证能够提供所有的支持. 如果你的 assistance 在 ...

  2. 关于deepin linux15.6-15.9.1系统播放视频卡顿解决办法

    关于deepin linux15.6-15.9.1系统播放视频卡顿解决办法 chrome浏览器 关闭chrome硬件加速模式 设置>高级>使用硬件加速模式 注释:由于视频卡顿是因显卡驱动问 ...

  3. IPv4和IPv6简单对比介绍(转载)

    原链接:https://baijiahao.baidu.com/s?id=1570208896149974&wfr=spider&for=pc 在配置计算机网络,特别是内网的时候,有时 ...

  4. Django框架第一篇基础

    一个小问题: 什么是根目录:就是没有路径,只有域名..url(r'^$') 补充一张关于wsgiref模块的图片 一.MTV模型 Django的MTV分别代表: Model(模型):和数据库相关的,负 ...

  5. 用flask实现的添加后保留原url搜索条件

    1.具体实现 #!usr/bin/env python # -*- coding:utf-8 -*- from flask import Flask,render_template,request,r ...

  6. 伪Ap接入点

    1.创建一个伪造的Ap接入点,必须购买一个无线网卡的设备,接受功率在300Mbps ,低于这个传输速率的值,效果很差,都达到用户可以连接验证的效果.其芯片必须支持kali linux 内核系统. 2. ...

  7. 基于Web的漏洞利用

    1.Nikto 基于Web的漏洞信息扫描 nikto 自动扫描web服务器上没有打补丁的软件,同时同时也检测驻留在服务器上的危险文件,nikto能够识别出特定的问题,检测服务器的配置问题, 检测某台主 ...

  8. java----Java的栈,堆,代码,静态存储区的存储顺序和位置

    转载:https://blog.csdn.net/zhangbaoanhadoop/article/details/82193497

  9. 广工赛-hdu6469-树链压缩/二分

    比较复杂的一题.. 不管是二分答案还是直接做,都需要压缩树链 /* 给定n种怪物,每个怪物有属性a[i] 打死第i种怪物后,第i只怪物会分裂成a[i]个第i-1种怪 如果打死的是第1种,那么获得经验a ...

  10. 两种lca的求法:树上倍增,tarjan

    第一种:树上倍增 f[x,k]表示x的2^k辈祖先,即x向根结点走2^k步达到的结点. 初始条件:f[x][0]=fa[x] 递推式:f[x][k]=f[ f[x][k-1] ][k-1] 一次bfs ...