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