結果

問題 No.3299 K-th MMA String
ユーザー toka0428
提出日時 2025-10-05 15:42:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 78,136 KB
最終ジャッジ日時 2025-10-05 15:42:31
合計ジャッジ時間 3,216 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
i = 6
count = 0
while True:
  c = 1
  pos = 1
  while pos < i:
    pos *= 2
    if pos <= i:
      c += 1
  S = []    
  for j in range(c-1,-1,-1):
    if i // (2**j) % 2 == 0:
      S.append("A")
    else:
      S.append("M")
  MMA = False
  for j in range(c-2):
    if S[j] == "M" and S[j+1] == "M" and S[j+2] == "A":
      MMA = True
  if MMA:
    count += 1
  if count == K:
    break
  i += 1
for x in range(N-c):
  print("A",end = "")
for x in range(c):
  print(S[x],end = "")
print()  
0