結果

問題 No.8 N言っちゃダメゲーム
ユーザー nanaenanae
提出日時 2017-04-17 22:01:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 632 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2023-09-26 10:57:28
合計ジャッジ時間 936 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,788 KB
testcase_01 AC 15 ms
7,780 KB
testcase_02 AC 16 ms
7,956 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def solve():
    def memo_rec(m):
        if m == 0:
            return True
        if dp[m] is not None:
            return dp[m]

        for i in range(1, k + 1):
            if m - i < 0:
                break
            if not memo_rec(m - i):
                dp[m] = True
                return True

        dp[m] = False
        return False

    P = int(input())

    for game in range(P):
        n, k = map(int, input().split())

        dp = [None] * (n + 1)
        dp[0] = True

        ans = memo_rec(n)

        ans = 'Win' if ans else 'Lose'

        print(ans)

if __name__ == '__main__':
    solve()
0