No.3299 K-th MMA String
問題文最終更新日: 2025-10-04 23:06:54
English (AI translation)
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
AandM. - $S$ contains
MMAat least $1$ time as a contiguous substring.
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もしくは右上の雲マークをクリックしてアカウントを作成してください。
sepa38
くらげ