結果
問題 | No.2766 Delicious Multiply Spice |
ユーザー |
![]() |
提出日時 | 2024-05-31 22:49:22 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 464 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-21 00:45:33 |
合計ジャッジ時間 | 2,970 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 8 |
other | AC * 31 |
ソースコード
n = int(input())d = dict()d[1] = 1def calc(x):if x in d: return d[x]if (x-1) % 2 == 0 and calc((x-1) // 2) == 1:d[x] = 1return 1if (x-1) % 3 == 0 and calc((x-1) // 3) == 1:d[x] = 1return 1d[x] = 0return 0assert(calc(n))x = na = []while x > 1:if (x-1) % 2 == 0 and calc((x-1)//2) == 1:x = (x-1) // 2a.append('A')else:assert (x-1) % 3 == 0 and calc((x-1)//3) == 1x = (x-1) // 3a.append('B')print(''.join(a[::-1]))