시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 26 | 14 | 13 | 52.000% |
The stones game is a simple game, it is also a very old game which is unknown to almost everyone.
The game starts with N stones and M players, the players are numbered from 1 to M. The players play in turns, player number 1 plays first, then player number 2 and so on until player number M plays, after this player number 1 plays again and they keep playing until the end of the game.
For each turn, the players do the following 2 steps:
This means in some turns a player might remove 0, 1 or 2 stones according to the above rules. In this game, the player who removes the last stone wins the game.
Now you are given the total number of stones, the total number of players and a player number and you are asked to answer the following question:
Is there a strategy for this player to win the game regardless of the actions taken by the other players in their turns?
Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). Followed by the test cases, each test case is described in one line which contains 3 integers separated by a single space N M X (1 ≤ N , M ≤ 109) and (1 ≤ X ≤ M) representing the number of stones, the number of players and the player number, respectively.
For each test case, print a single line which contains a single word, this word is either “YES” or “NO” (without the quotes) representing the answer for the above question for the given player number.
2 2 2 2 2 2 1
YES NO