An Ordinary Game(博弈)

Problem Statement

There is a string ss of length 33 or greater. No two neighboring characters in ss 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 ss, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in ss.

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|≤1053≤|s|≤105

  • ss consists of lowercase English letters.

  • No two neighboring characters in ss are equal.

Input

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

ss

Output

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

Sample Input 1 Copy
aba

Sample Output 1 Copy
Second

Takahashi, who goes first, cannot perform the operation, since removal of the b, which is the only character not at either ends of ss, would result in ssbecoming aa, with two as neighboring.

大意:从一个任意左右不相邻的字符串中(除去两端)取出一个字符,要保证取出字符后该字符的左右两个字符不相等,每人取一次,最后谁取不了,谁就输;

思路:为了保证自己赢,每一位选手都会拆除对方的圈套,那么他们俩一定能够对抗到最后,这时就要看两端字符是否一样了;

#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	int n=a.size();
	if(a[0]==a[n-1])	//两端字符相等; 
	{
		if(n%2==0) cout<<"First";	//中间有偶数个,最后一个不能取,先取的赢; 
		else cout<<"Second";
	}
	else				//两端字符不等; 
	{
		if(n%2==0) cout<<"Second";	//中间有偶数个,能全部取完,先取的败; 
		else cout<<"First";
	}
	return 0;
} 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值