6486: An Ordinary Game(规律)
题目描述
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.
输入
s
输出
样例输入
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(规律)的更多相关文章
- Flower(规律+逆向思维)
Flower: 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6486 题解: 逆向思维+规律 因为每次剪n-1,所以逆向就是控制n-1朵不变,每次增高1 ...
- hdu1452 Happy 2004(规律+因子和+积性函数)
Happy 2004 题意:s为2004^x的因子和,求s%29. (题于文末) 知识点: 素因子分解:n = p1 ^ e1 * p2 ^ e2 *..........*pn ^ en 因子 ...
- 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 ...
- ACM/ICPC 之 DP解有规律的最短路问题(POJ3377)
//POJ3377 //DP解法-解有规律的最短路问题 //Time:1157Ms Memory:12440K #include<iostream> #include<cstring ...
- HDU 5795 A Simple Nim 打表求SG函数的规律
A Simple Nim Problem Description Two players take turns picking candies from n heaps,the player wh ...
- 在sqlserver中做fibonacci(斐波那契)规律运算
--利用sqlserver来运算斐波那契规律 --利用事物与存储过程 declare @number intdeclare @A intdeclare @B intdeclare @C int set ...
- 谈谈黑客攻防技术的成长规律(aullik5)
黑莓末路 昨晚听FM里谈到了RIM这家公司,有分析师认为它需要很悲催的裁员90%,才能保证活下去.这是一个意料之中,但又有点兔死狐悲的消息.可能在不久的将来,RIM这家公司就会走到尽头,或被收购,或申 ...
- Math.abs(~2018),掌握规律即可!
Math.abs(~2018) 某前端群的入门问题长姿势了,一个简单的入门问题却引发了我的思考,深深的体会到自己在学习前端技术的同时忽略遗忘了一些计算机的基础知识. 对于 JS Math对象没什么可说 ...
- COM中需要调用AddRef和Release的10条规律
COM中需要调用AddRef和Release的10条规律
随机推荐
- ant 安装 网址
1 http://www.testautomationguru.com/jmeter-continuous-performance-testing-part1/ 2 http://www.testau ...
- SQL Server 函数之日期格式化函数
SQL Server 函数之日期格式化函数 高文龙关注0人评论612人阅读2017-09-23 13:47:07 SQL Server 函数之日期格式化函数 对于一些经常写SQL Server执行语句 ...
- ORA-00257: archiver error. Connect internal only, until freed.| Oracle数据库归档日志满导致应用系统反应缓慢的问题处理
一:查看原因 查看了下V$FLASH_RECOVERY_AREA_USAGE,看看归档目录使用的情况.果然是归档满了. Disconnected from Oracle Database 11g En ...
- SpringData分页功能
在SpringData中实现分页功能我们需要将接口实现PagingAndSortingRepository这个接口提供了分页查询的方法 Page<T> findAll(Pageable p ...
- 复习os模块常用的一些操作
import os # 1.切换路径============= d = os.getcwd() #获取当前的工作路径 os.chdir('D:\\')#目录的切换 print(os.getcwd()) ...
- BeautifulSoup的基本操作
>>> from bs4 import BeautifulSoup #导入 >>> soup = BeautifulSoup(url.content," ...
- Synchronized和java.util.concurrent.locks.Lockde区别联系
1.Lock能够完成几乎所有synchronize的功能,并且具有锁投票,定时锁,可中断等候锁,synchronize是java语言层面的,是内置的关键字,Lock是一个包,synchronize使用 ...
- jmeter BeanShell实例-----两个变量之间的断言对比
jmeter BeanShell实例-----两个变量之间的断言对比 在jmeter的中,断言没法对两个变量的进行对比后判断,只能使用Bean Shell断言来进行,总是有人来问怎么写呢.这里写一个简 ...
- C/C++返回内部静态成员的陷阱(转)
在我们用C/C++开发的过程中,总是有一个问题会给我们带来苦恼.这个问题就是函数内和函数外代码需要通过一块内存来交互(比如,函数返回字符串),这个问题困扰和很多开发人员.如果你的内存是在函数内栈上分配 ...
- 20165206 2017-2018-2 《Java程序设计》第七周学习总结
20165206 2017-2018-2 <Java程序设计>第七周学习总结 教材学习内容总结 MySqL:是世界上最流行的开源数据管理系统. 配置启动MySQL. 连接数据库:Conne ...