Answer the question
In order to leave comments, you need to log in
How to solve the Bache math game problem?
The essence of the problem:
There are N items, players take turns taking from 1 to K items, the winner is the one who takes the last item.
The task is to analyze the played game and for each move to determine whether it is correct or erroneous. An erroneous move - if in this situation it was possible to go differently, guaranteeing yourself a win in the future, regardless of the opponent's game. A correct move is a move that is not erroneous.
In addition, when the position is losing, then any move is correct, because. it can be considered optimal due to the fact that the result is still a loss.
Input data:
N, K, P - the number of moves made by the players. P moves.
(2 ≤ N ≤ 10000, 2 ≤ K ≤ 100, 2 ≤ P)
Examples:
Input
10 5 3
3
3
4
Output
F
F
T
Input
10
5 3
4
3
3
Output
T
T
T
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question