1214 : square game
| 比对Compare | token 相同即通过。中间的空格、制表符、换行可多可少。Matching tokens pass. Extra spaces, tabs, or newlines between them are ignored. |
|---|---|
| 不同则错Differs | token 个数或内容不同即错误。23 与 2 3、02 与 2、2.0 与 2 均视为不同。A different token count or value is wrong. 23 vs 2 3, 02 vs 2, and 2.0 vs 2 all differ. |
| 输入Input | 标准输入,格式见题面。Standard input; format as in the statement. |
| 输出Output | 标准输出。Standard output. |
题目描述Description
The square game is a two play game played with \(n\) piles of stones. Each pile has a positive integer number of stones \(a_i\).
Two players take turns making move. In each move, the current player chooses one pile and remove one or more stones from the pile satisfying following rules: Use the pile of stones to pile a maximal square, remove the remain stones in the pile, then remove arbitrary number of rows of the square.
In other words, if the player choose a pile with \(m\) stones, then he could remove \((m-\lfloor\sqrt{m}\rfloor^2+k\lfloor\sqrt m\rfloor)\) stones from the pile.(\(0\le k\le\lfloor \sqrt m\rfloor\) and \(k\not=0\) if \(m=\lfloor\sqrt m\rfloor^2\)).
The game ends when every stones are removed. The winner is the player who remove the last stone.
Find the result of the game when both players play optimally.The square game is a two play game played with \(n\) piles of stones. Each pile has a positive integer number of stones \(a_i\).
Two players take turns making move. In each move, the current player chooses one pile and remove one or more stones from the pile satisfying following rules: Use the pile of stones to pile a maximal square, remove the remain stones in the pile, then remove arbitrary number of rows of the square.
In other words, if the player choose a pile with \(m\) stones, then he could remove \((m-\lfloor\sqrt{m}\rfloor^2+k\lfloor\sqrt m\rfloor)\) stones from the pile.(\(0\le k\le\lfloor \sqrt m\rfloor\) and \(k\not=0\) if \(m=\lfloor\sqrt m\rfloor^2\)).
The game ends when every stones are removed. The winner is the player who remove the last stone.
Find the result of the game when both players play optimally.
输入格式Input
The first line contains one integer \(n\) \((1 \leq n \leq 10^5)\), represents the number of piles.
The second line contains \(n\) integers \(a_1,a_2\ldots,a_n\) \((1 \leq a_i \leq 10^6)\), represent the number of stones in each piles.
输出格式Output
Output ‘’First’’ if the first player wins, otherwise ‘’Second’’.