結果

問題 No.2766 Delicious Multiply Spice
ユーザー 学ぶマン
提出日時 2025-02-18 22:20:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2025-02-18 22:20:20
合計ジャッジ時間 3,417 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
sys.setrecursionlimit(10**8)

ans = []
def dfs(record:list, x:int):
    global ans
    if x == 1:
        ans = record[:]
        return

    if (x - 1)%2 == 0:
        record.append('A')
        newx = (x - 1)//2
        dfs(record, newx)
        record.pop()

    if (x - 1)%3 == 0:
        record.append('B')
        newx = (x - 1)//3
        dfs(record, newx)
        record.pop()

N = int(input())
if N == 1:
    exit(print())

dfs([], N)
ans.reverse()
print(''.join(ans))
0