結果

問題 No.7 プライムナンバーゲーム
ユーザー 井筒麗稀
提出日時 2025-07-23 00:39:11
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 336 ms / 5,000 ms
コード長 634 bytes
コンパイル時間 484 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2025-07-23 00:39:16
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    pn = []
    dp = [False] * (N + 1)
    
    for i in range(2, N + 1):    #素数の確保
        for j in range(2, int(i ** 0.5) + 1):
            if i % j == 0:
                break
        else:
            pn.append(i)

    dp[0] = dp[1] = False

    for i in range(2, N + 1):
        for j in pn:
            if j > i:
                break
            if i - j <= 1:
                continue
            if dp[i - j] == False:
                dp[i] = True
                break

    if dp[N] == True:
        print("Win")
    else:
        print("Lose")

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