問題一覧 > 通常問題

No.3299 K-th MMA String

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 104
作問者 : sepa38 / テスター : dyktr_06 くらげ Nafmo2 hanba-gu1
お気に入りにしたユーザー ProblemId : 11270 / 自分の提出
問題文最終更新日: 2025-10-04 23:06:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest MMA Contest 020 (順位表) の他の問題:

Problem Statement

A string $S$ satisfying the following conditions is defined as an MMA string.

  • It consists only of A and M.
  • $S$ contains MMA at least $1$ time as a contiguous substring.
Output the $K$-th lexicographically smallest MMA string of length $N$.

Constraints

  • All inputs are integers.
  • $3 \leq N \leq 10^5$
  • $1 \leq K \leq 10^5$
  • There exist at least $K$ distinct MMA strings of length $N$.

Input

$N\ K$

Output

Output the $K$-th lexicographically smallest MMA string of length $N$.

Sample

Sample 1
Input
3 1
Output
MMA

The only MMA string of length 3 is MMA, so MMA is the answer.

Sample 2
Input
4 3
Output
MMAM

There are 4 MMA strings of length 4: AMMA, MMAA, MMAM, and MMMA. Among them, the 3rd lexicographically smallest is MMAM, which is the answer.

Sample 3
Input
15 25505
Output
MMAMMAMMAMMAMMA

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。