#P11056. Fire and Big
Fire and Big
Problem Description
Little F wants to play a game with others, but he does not want to lose, so he asks you to help him study a strategy.
There are stones. Little F and Little B take turns removing stones. Little F goes first. The player who cannot make a move loses.
Given a positive integer , the number of stones removed each time ( is a positive integer) must satisfy at least one of the following two conditions:
- is a multiple of .
- is a perfect square less than .
They will play games. In each game, is fixed, and only the number of stones changes.
For each game, assuming both players are smart enough, determine who has a winning strategy.
Input Format
The first line contains two positive integers .
The second line contains positive integers , where each is the number of stones in that game.
Output Format
Output a string of length , one character per game. Each character is F or B, meaning the first player wins or the second player wins in that game, respectively.
5 2
1 2 3 4 5
FFBFF
Hint
Sample Explanation
The following explains that when , the second player will win. Consider the number of stones the first player removes on the first move:
- If the first player removes stone, then the second player can remove all remaining stones.
- If the first player removes stones, then the second player can remove the remaining stone.
Therefore, no matter what, the second player will always win.
Constraints
| Test Point ID | ||
|---|---|---|
For all testdata, it is guaranteed that and .
For odd-numbered test points, the memory limit is ; for even-numbered test points, the memory limit is .
Translated by ChatGPT 5