結果

問題 No.1465 Archaea
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-02 22:08:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 7,944 KB
最終ジャッジ日時 2023-08-25 16:16:41
合計ジャッジ時間 1,265 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,792 KB
testcase_01 AC 14 ms
7,860 KB
testcase_02 AC 14 ms
7,924 KB
testcase_03 AC 14 ms
7,944 KB
testcase_04 AC 14 ms
7,860 KB
testcase_05 AC 13 ms
7,804 KB
testcase_06 AC 13 ms
7,940 KB
testcase_07 AC 13 ms
7,800 KB
testcase_08 AC 12 ms
7,900 KB
testcase_09 AC 13 ms
7,808 KB
testcase_10 AC 13 ms
7,796 KB
testcase_11 AC 13 ms
7,796 KB
testcase_12 AC 13 ms
7,788 KB
testcase_13 AC 13 ms
7,716 KB
testcase_14 AC 12 ms
7,792 KB
testcase_15 AC 12 ms
7,800 KB
testcase_16 AC 13 ms
7,792 KB
testcase_17 AC 15 ms
7,896 KB
testcase_18 AC 14 ms
7,800 KB
testcase_19 AC 14 ms
7,808 KB
testcase_20 AC 14 ms
7,804 KB
testcase_21 AC 13 ms
7,796 KB
testcase_22 AC 14 ms
7,812 KB
testcase_23 AC 13 ms
7,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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")

    
0