CF87C.Interesting Game
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Two best friends Serozha and Gena play a game.
Initially there is one pile consisting of n stones on the table. During one move one pile should be taken and divided into an arbitrary number of piles consisting of _a_1 > _a_2 > ... > a__k > 0 stones. The piles should meet the condition _a_1 - _a_2 = _a_2 - _a_3 = ... = a__k - 1 - a__k = 1. Naturally, the number of piles k should be no less than two.
The friends play in turns. The player who cannot make a move loses. Serozha makes the first move. Who will win if both players play in the optimal way?
两位最好的朋友谢罗扎(Serozha)和热纳(Gena)正在玩一个游戏。
初始时,桌上有一堆共 n 颗石子。在一次操作中,玩家需选取一堆石子,并将其任意分成 k 堆,各堆石子数分别为 a1>a2>⋯>ak>0,且满足条件:
a1−a2=a2−a3=⋯=ak−1−ak=1.
显然,分出的堆数 k 至少为 2。
两人轮流进行操作。无法进行操作的玩家判负。谢罗扎先手。若双方均以最优策略进行游戏,谁将获胜?
输入格式
The single line contains a single integer n (1 ≤ n ≤ 105).
单行包含一个整数 n(1 ≤ n ≤ 105)。
输出格式
If Serozha wins, print k, which represents the minimal number of piles into which he can split the initial one during the first move in order to win the game.
If Gena wins, print "-1" (without the quotes).
如果谢罗扎获胜,输出 k,表示他在第一步中将初始堆分割成的最少堆数,以确保赢得游戏。
如果格纳获胜,输出 "-1"(不带引号)。
输入输出样例
输入#1
3
输出#1
2
输入#2
6
输出#2
-1
输入#3
100
输出#3
8
输入解题思路,AI测评打分。不知道怎么写?