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

23393번 - Getting in Shape 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB819917.647%

문제

Juan decided to start working out and is willing to prepare a workout session.

He knows that some days he might not want to do all exercises from his workout session. He decided on some rules to avoid skipping the whole session and not exercising at all, while still allowing him to optionally skip some exercises.

The rules are:

  • There will be only two types of exercises: A and B.
  • After finishing an exercise of type B he moves to the next exercise, if there is one. Otherwise, the workout session ends.
  • After finishing an exercise of type A there are two possibilities: he can move to the next exercise, or he can skip the next exercise and move to the one after that.
  • The last exercise in a workout session must always be of type B.

Therefore, there might be different ways in which the workout session can be completed. For example, if the types of exercises in a workout session are BAAB, there are 3 ways in which the session can be completed: by doing all exercises, by skipping the 3rd one or by skipping the last one.

Juan wants to prepare his workout session in such a way that there are exactly N different ways in which the workout session can be completed. Can you help him?

입력

One positive integer N (2 ≤ N ≤ 1015), representing the number of ways in which the workout session can be completed.

출력

Output a line containing a string, formed only with characters ‘A’ and ‘B’, representing the types of the exercises in the workout session. If there are multiple valid answers, output the lexicographically smallest answer. If there is no valid workout sessions, output a line containing the string “IMPOSSIBLE” (without quotes).

제한

예제 입력 1

2

예제 출력 1

AB

예제 입력 2

4

예제 출력 2

ABAB

예제 입력 3

7

예제 출력 3

IMPOSSIBLE

힌트

출처

ICPC > Regionals > Latin America > Sub-Regional Brasil do ACM ICPC > Maratona de Programação SBC 2021 G번

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

출처

대학교 대회

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

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