結果
問題 |
No.2766 Delicious Multiply Spice
|
ユーザー |
![]() |
提出日時 | 2024-08-15 14:01:33 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,050 bytes |
コンパイル時間 | 308 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 70,384 KB |
最終ジャッジ日時 | 2024-08-15 14:01:37 |
合計ジャッジ時間 | 3,692 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 8 |
other | RE * 31 |
ソースコード
import pypyjit pypyjit.set_param('max_unroll_recursion=-1') # https://yukicoder.me/problems/no/2766 from typing import Self class Node: def __init__(self, value, spice='', parent=None) -> None: self.value: int = value self.spice: str = spice self.parent: Self | None = parent def dig(self): if self.value == 1: return self if (self.value - 1) % 2 == 0: if goal := Node(value=(self.value - 1) / 2, spice='A', parent=self).dig(): return goal if (self.value - 1) % 3 == 0: if goal := Node(value=(self.value - 1) / 3, spice='B', parent=self).dig(): return goal def list_spices(self): spices = ['', self.spice] node = self while (p := node.parent) and p.spice: spices.append(p.spice) node = p return spices if __name__ == '__main__': N = int(input()) node = Node(value = N) goal = node.dig() print(''.join(goal.list_spices()))