An Ordinary Game(简单推导)
An Ordinary Game
Time limit : 2sec / Memory limit : 256MB
Score : 500 points
Problem Statement
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.
Input
The input is given from Standard Input in the following format:
s
Output
If Takahashi will win, print First. If Aoki will win, print Second.
Sample Input 1
aba
Sample Output 1
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.
Sample Input 2
abc
Sample Output 2
First
When Takahashi removes b from s, it becomes ac. Then, Aoki cannot perform the operation, since there is no character in s, excluding both ends.
Sample Input 3
abcab
Sample Output 3
First //有一个字符串,相邻的不能相同,两个人玩,一人每次可以删除除了首尾的任意一个,但是要保证删完不能相邻的相同,谁删到不能删就谁输,
给一个字符串,问谁赢
#include <stdio.h>
#include <string.h> char str[];
int main()
{
while (scanf("%s",str)!=EOF)
{
int len=strlen(str);
int res;
if (str[]==str[len-])
res=len-;
else
res=len-;
if (res%==)
printf("First\n");
else printf("Second\n");
}
return ;
}
An Ordinary Game(简单推导)的更多相关文章
- 贝塞尔曲线.简单推导与用opengl实现动态画出。
在opengl中,我们可以用少许的参数来描述一个曲线,其中贝塞尔曲线算是一种很常见的曲线控制方法,我们先来看维基百科里对贝塞尔曲线的说明: 线性贝塞尔曲线 给定点P0.P1,线性贝塞尔曲线只是一条两点 ...
- Python学习3——Python的简单推导
列表推导是一种从其他列表创建列表的方式,类似于数学中的集合推导,列表推导的工作原理非常简单,类似于for循环.(以下代码均在IDLE实现) 最简单的列表推导: >>>[x*x for ...
- HIT手 | 机械电气构造简述和微分运动学及静力学的简单推导
机械结构电气构造简述 HIT手有四个手指,每个手指4个关节,其中第一和第二个关节正交,第三和第四个关节机械耦合,故只有3个自由度,另外大拇指多了一个相对手掌运动的自由度,故一只手掌总共有13各个自 ...
- Codeforces Round #554 (Div. 2) C. Neko does Maths (简单推导)
题目:http://codeforces.com/contest/1152/problem/C 题意:给你a,b, 你可以找任意一个k 算出a+k,b+k的最小公倍数,让最小公倍数尽量小,求出 ...
- Logistic Regression 的简单推导
Logistic Regression 是一种 Generalized Linear Model(GLM),也即广义线性模型. 1. LR 的基本假设 LR 模型假设观测值 y 成立的对数几率(log ...
- 简单推导 PCA
考虑二维数据降低到一维的例子,如下图所示: 最小化投影方差(maximize projected variance): 1N∑n=1N(uuT1xn−uuT1x¯)=uuT1Suu1,s.t.uuT1 ...
- Pytorch Linear ()简单推导
pytorch,nn.Linear 下图中的A是权重矩阵,b是偏置. in_features输入样本的张量大小 out_features输出样本的张量大小 bias是偏置 # 测试代码 # batch ...
- 【LOJ#3197】【eJOI2019】T形覆盖 - (图论、简单推导)
题面 题解 (题目中说的四种摆放方式实际上是分别旋转0°,90°,180°,270°后的图形) 题目中关于摆放方式的描述听起来很臭,我们把它转换一下,每个拼版先覆盖"上下左右中"五 ...
- OpenGL中投影矩阵的推导
本文主要是对红宝书(第八版)第五章中给出的透视投影矩阵和正交投影矩阵做一个简单推导.投影矩阵的目的是:原始点P(x,y,z)对应后投影点P'(x',y',z')满足x',y',z'∈[-1,1]. 一 ...
随机推荐
- 直方图均衡(HE)与局部色调映射(LTM) .
直方图均衡(Histogram Equalization)是图像处理中一个十分基础的概念,具有调整图像灰度,增强对比度的作用. 限制对比度自适应直方图均衡(Contrast Limited Ad ...
- JS方面重点摘要(一)
1.获取样式(1)style只能获取到行间样式的属性(2)火狐getComputedStyle(obj,null)[attr],IE:obj.currentStyle[attr] 2.ready.on ...
- 启动sping的时候可以使用system.in.read()暂停
启动sping的时候可以使用system.in.read()暂停 只要不输入就可以不会停了:
- android中Invalidate和postInvalidate的差别
Android中实现view的更新有两组方法,一组是invalidate.还有一组是postInvalidate.当中前者是在UI线 程自身中使用,而后者在非UI线程中使用. Android提供了In ...
- 状态机工作流,顺序工作流和Flowchart
什么是工作流,工作流可以说是对业务处理过程的建模,当我们设计工作流的时候,我们首先要分析业务处理过程中要经历的步骤.然后,我们就可以利用WF创建工作流模型来模拟业务的处理过程. WF工作流包含两种类型 ...
- 设计模式——浅复制VS深复制
背景 在学习原型模式的时候,採用了一个差别与其它模式的新方法.採用了"克隆(Clone)方法.通过实现ICloneable接口中的Clone()方法来达到克隆的目的. 代码实现过程中,存在了 ...
- 【Python数据分析】
索引对象的其他功能 ①更换索引 ②对齐 ③删除 一.更换索引 我们已经知道,数据结构一旦声明,index对象就不能改变 事实上,我们重新定义索引之后,我们就能够用现有的数据结构生成一个新的数据机构 p ...
- JQuery DataTables学习
1.Datatables简单介绍 DataTables是一个jQuery的表格插件.这是一个高度灵活的工具,根据的基础逐步增强,这将添加先进的互动控制.支持不论什么HTML表格. 主要特点: 自己主动 ...
- Android实用工具
1 json类:hiJson 格式化json字符串 2 sqlite类:sqlitespy,SQLiteExpertSetup 3
- JFinal中Controller的应用
部分方法: 1.获取参数:getPara(String name); getParaToInt(String name) ,将返回参数的值转为int: getPara() ,url中参数连接为/v1- ...