Logo
(追記) (追記ここまで)

31648번 - Palindrome Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB46626223357.531%

문제

Bessie and Elsie are playing a game with a pile of stones that initially contains $S$ stones (1ドル\le S<10^{10^5}$). The two cows alternate turns, with Bessie going first. When it is a cow's turn, she must remove $x$ stones from the pile, where $x$ 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 $T$ (1ドル\le T\le 10$) independent test cases. For each test case, print who wins the game if both cows play optimally.

입력

The first line contains $T,ドル the number of test cases. The next $T$ lines describe the test cases, one line per test case.

Each test case is specified by a single integer $S$.

출력

For each test case, output B if Bessie wins the game under optimal play starting with a pile of stones of size $S,ドル or E otherwise, on a new line.

제한

예제 입력 1

3
8
10
12

예제 출력 1

B
E
B

For the first test case, Bessie can remove all the stones on her first move, since 8ドル$ is a palindrome, guaranteeing her win.

For the second test case, 10ドル$ 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.

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2024 February Contest > Bronze 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /