2023: [USACO 2024 February Contest Bronze] Problem 1. Palindrome Game
题目描述
Bessie and Elsie are playing a game with a pile of stones that initially contains stones (). The two cows alternate turns, with Bessie going first. When it is a cow's turn, she must remove stones from the pile, where is any positive integer palindrome of the cow's choosing. If the pile is empty when a cow's turn starts, that cow loses.
Definition: A positive integer is a palindrome if it reads the same forward and backward; examples of palindromes include 1, 121, and 9009. Leading zeros are not allowed; e.g., 990 is *not* a palindrome.
There are () independent test cases. For each test case, print who wins the game if both cows play optimally.
输入
Each test case is specified by a single integer .
输出
样例输入
3
8
10
12
样例输出
B
E
B
提示
For the first test case, Bessie can remove all the stones on her first move, since is a palindrome, guaranteeing her win.
For the second test case, is not a palindrome, so Bessie cannot remove all the stones on her first move. Regardless of how many stones Bessie removes on her first move, Elsie can always remove all remaining stones on her second move, guaranteeing her win.
For the third test case, it can be proven that Bessie wins under optimal play.
SCORING:
- Inputs 2-4:
- Inputs 5-7:
- Inputs 8-10:
- Inputs 11-13: No additional constraints.