結果

問題 No.7 プライムナンバーゲーム
ユーザー mediocreRailmediocreRail
提出日時 2023-08-15 08:40:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,060 ms / 5,000 ms
コード長 825 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 10,760 KB
実行使用メモリ 9,712 KB
最終ジャッジ日時 2023-08-15 08:40:18
合計ジャッジ時間 16,058 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
9,564 KB
testcase_01 AC 23 ms
9,528 KB
testcase_02 AC 2,045 ms
9,584 KB
testcase_03 AC 137 ms
9,540 KB
testcase_04 AC 53 ms
9,496 KB
testcase_05 AC 51 ms
9,496 KB
testcase_06 AC 604 ms
9,532 KB
testcase_07 AC 397 ms
9,508 KB
testcase_08 AC 182 ms
9,588 KB
testcase_09 AC 820 ms
9,568 KB
testcase_10 AC 25 ms
9,568 KB
testcase_11 AC 385 ms
9,712 KB
testcase_12 AC 1,444 ms
9,508 KB
testcase_13 AC 1,541 ms
9,540 KB
testcase_14 AC 2,060 ms
9,492 KB
testcase_15 AC 1,972 ms
9,564 KB
testcase_16 AC 1,695 ms
9,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect,collections,itertools,math,functools,heapq
import sys
#sys.setrecursionlimit(10**6)
def I(): return int(sys.stdin.readline().rstrip())
def IN(): return int(input())
def LIN(): return list(map(int, input().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LF(): return list(map(float,sys.stdin.readline().rstrip().split()))
def SI(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

"""
方針
"""

n = 10**4
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))

primes=sorted(primes)

N=I()
dp = [False]*(N+1)

for i in range(2, N):
    for v in primes:
        if i+v > N: break
        dp[i+v] = dp[i+v] or not dp[i]
if dp[N]:
    print('Win')
else:
    print('Lose')
0