結果

問題 No.1465 Archaea
ユーザー sgswsgsw
提出日時 2021-05-05 19:31:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 960 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-13 12:26:15
合計ジャッジ時間 1,906 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 20
権限があれば一括ダウンロードができます

ソースコード

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()
sys.setrecursionlimit(10000000000)
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