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.
The input is given from Standard Input in the following format:
ssIf Takahashi will win, print First. If Aoki will win, print Second.
Copy
abaCopy
SecondTakahashi, 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.
Copy
abcCopy
FirstWhen Takahashi removes b from ss, it becomes ac. Then, Aoki cannot perform the operation, since there is no character in ss, excluding both ends.
Copy
abcabCopy
First题意:
给你一个字符(任意相邻的两个字符都不相同)两个人进行博弈,每个人只能从中间去(最左边和最右边的不能取)取这个字符要保证去取完之后任意相邻的两个字符串都不相同,否则这个字符就不能取。问最后谁能获胜。
思路:
如果两端的字符不相等(那么中间的字符能取完)。如果两端的相等中间的字符要生一个不能取。
然后分奇数偶数讨论就行了。
代码:
#include<bits/stdc++.h> using namespace std; char s[100009]; int main() { scanf("%s",&s); int n=strlen(s); if(s[0]==s[n-1]) { n--; } if(n%2==1) { cout<<"First"<<endl; } else { cout<<"Second"<<endl; } }
