結果

問題 No.2766 Delicious Multiply Spice
ユーザー KudeKude
提出日時 2024-05-31 21:39:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 56,688 KB
最終ジャッジ日時 2024-05-31 21:39:46
合計ジャッジ時間 3,313 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
55,820 KB
testcase_01 AC 44 ms
55,920 KB
testcase_02 AC 46 ms
55,916 KB
testcase_03 AC 46 ms
55,004 KB
testcase_04 AC 45 ms
55,064 KB
testcase_05 AC 46 ms
55,824 KB
testcase_06 AC 46 ms
56,060 KB
testcase_07 AC 46 ms
56,328 KB
testcase_08 AC 46 ms
55,208 KB
testcase_09 AC 45 ms
55,664 KB
testcase_10 AC 45 ms
56,244 KB
testcase_11 AC 51 ms
55,100 KB
testcase_12 AC 47 ms
56,076 KB
testcase_13 AC 47 ms
54,920 KB
testcase_14 AC 46 ms
56,044 KB
testcase_15 AC 44 ms
55,540 KB
testcase_16 AC 46 ms
55,696 KB
testcase_17 AC 46 ms
55,068 KB
testcase_18 AC 46 ms
56,300 KB
testcase_19 AC 46 ms
55,000 KB
testcase_20 AC 46 ms
55,704 KB
testcase_21 AC 46 ms
55,144 KB
testcase_22 AC 46 ms
56,404 KB
testcase_23 AC 46 ms
54,864 KB
testcase_24 AC 47 ms
55,724 KB
testcase_25 AC 46 ms
55,632 KB
testcase_26 AC 46 ms
56,056 KB
testcase_27 AC 44 ms
54,908 KB
testcase_28 AC 45 ms
56,060 KB
testcase_29 AC 46 ms
55,252 KB
testcase_30 AC 45 ms
55,168 KB
testcase_31 AC 45 ms
55,288 KB
testcase_32 AC 46 ms
55,696 KB
testcase_33 AC 46 ms
56,096 KB
testcase_34 AC 46 ms
55,364 KB
testcase_35 AC 45 ms
55,168 KB
testcase_36 AC 45 ms
55,228 KB
testcase_37 AC 47 ms
56,688 KB
testcase_38 AC 46 ms
55,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import cache
@cache
def f(n):
    if n == 1:
        return True
    n -= 1
    return n % 2 == 0 and f(n // 2) or n % 3 == 0 and f(n // 3)

n = int(input())
ans = []
while n != 1:
    n -= 1
    if n % 2 == 0 and f(n // 2):
        n //= 2
        ans.append('A')
    else:
        assert n % 3 == 0
        n //= 3
        ans.append('B')
ans.reverse()
print(''.join(ans))
0