#QHD0000015. Trò chơi lấy đá (Stones)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Trò chơi lấy đá (Stones)
Stones
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Two players play a stone-removal game. There are initially stones and distinct positive integers describing the allowed numbers of stones to remove in a turn.
The first player moves first. On each turn, a player must remove exactly stones for some allowed value, provided enough stones remain. A player with no legal move loses.
Assuming that both players play optimally, determine whether the first or second player wins.
Input
The first line contains and , the number of allowed move sizes and the initial stone count.
The second line contains integers in increasing order.
Output
Print First if the first player wins under optimal play; otherwise print Second.
Subtasks
- Subtask 1 (20 points): ; ; ; The are distinct positive integers in increasing order.
- Subtask 2 (30 points): ; ; ; The are distinct positive integers in increasing order.
- Subtask 3 (50 points): ; ; ; The are distinct positive integers in increasing order.
Examples
Input
2 4
2 3
Output
First
Explanation
There are stones, and each move removes or . The first player removes , leaving . The second player has no legal move and loses, so the answer is First.