RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0603

Palindrome Game

Gold IV 골드 IV
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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.

Problem credits: Nick Wu

제약

SCORING

  • Inputs 2-4: \(S<100\)
  • Inputs 5-7: \(S<10^6\)
  • Inputs 8-10: \(S<10^9\)
  • Inputs 11-13: No additional constraints.

Problem credits: Nick Wu

입력 형식

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
출력
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.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > February > Bronze

태그

평가 및 의견

Palindrome Game

개요
출제자 난이도 Gold IV 골드 IV 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Palindrome Game

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8