結果

問題 No.1465 Archaea
ユーザー sgswsgsw
提出日時 2021-05-05 19:30:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 926 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 78,568 KB
最終ジャッジ日時 2023-10-11 13:41:59
合計ジャッジ時間 3,715 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,856 KB
testcase_01 AC 17 ms
7,792 KB
testcase_02 AC 29 ms
10,264 KB
testcase_03 AC 15 ms
7,928 KB
testcase_04 AC 16 ms
7,772 KB
testcase_05 AC 16 ms
7,860 KB
testcase_06 AC 16 ms
7,860 KB
testcase_07 AC 279 ms
42,256 KB
testcase_08 AC 19 ms
8,784 KB
testcase_09 AC 24 ms
9,420 KB
testcase_10 AC 16 ms
7,864 KB
testcase_11 AC 345 ms
49,568 KB
testcase_12 AC 106 ms
25,084 KB
testcase_13 RE -
testcase_14 AC 55 ms
13,352 KB
testcase_15 AC 15 ms
7,984 KB
testcase_16 AC 16 ms
7,776 KB
testcase_17 AC 16 ms
8,384 KB
testcase_18 AC 16 ms
7,860 KB
testcase_19 AC 15 ms
7,840 KB
testcase_20 AC 16 ms
8,312 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 16 ms
7,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def input():
    return sys.stdin.readline().rstrip()

"""
Do not get stuck on a problem for more than 20 minutes
Just check the editorial :)
There should be something else to do insead
"""
memo = dict()

def possible(N,K):
    if (N,K) in memo:
        return memo[(N,K)]
    if N == 1 and K >= 0:
        res = True
        memo[(N,K)] = res
        return res
    if N <= 0:
        return False
    if K == 0:
        res = bool(N == 1)
        memo[(N,K)] = res
        return res 
    #N > 0 K > 0
    if N % 2 == 0:
        res = possible(N//2,K - 1) | possible(N - 3,K - 1)
    else:
        res = possible(N - 3,K - 1)
    memo[(N,K)] = res 
    return res
    
def slv():
    n,k = map(int,input().split())
    if possible(n,k):
        print("YES")
    else:
        print("NO")
    return 

def main():
    t = 1
    for i in range(t):
        slv()
    return 


if __name__ == "__main__":
    main()
0