結果
問題 | No.1465 Archaea |
ユーザー |
|
提出日時 | 2021-04-02 22:08:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 110 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-12-24 01:19:30 |
合計ジャッジ時間 | 1,704 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
import sys sys.setrecursionlimit(10**6) n,k = map(int,input().split()) dic = {} def dfs(x,left): if (x,left) in dic: return dic[(x,left)] if x < 1: return 0 if x == 1: return 1 if left == 0 and x != 1: return 0 if (x-1)%3 == 0 and (x-1)//3 <= left: check = 1 dic[(x,left)] = check return check check = 0 if x%2 == 0: check |= dfs(x//2,left-1) else: check |= dfs(x-3,left-1) dic[(x,left)] = check return check print("YES" if dfs(n,k) else "NO")