結果

問題 No.2766 Delicious Multiply Spice
ユーザー shimon
提出日時 2024-06-09 22:40:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 54,116 KB
最終ジャッジ日時 2024-12-31 02:57:57
合計ジャッジ時間 3,050 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit
setrecursionlimit(10**6)


def dfs(N):
    if N == 1:
        return ('', True)
    if (N - 1) % 2 == 0:
        res = dfs((N - 1) // 2)
        if res[1]:
            return (res[0] + 'A', True)
    if (N - 1) % 3 == 0:
        res = dfs((N - 1) // 3)
        if res[1]:
            return (res[0] + 'B', True)
    return ('', False)


print(dfs(int(input()))[0])
0