結果

問題 No.7 プライムナンバーゲーム
ユーザー AtamaokaCAtamaokaC
提出日時 2021-06-19 17:09:25
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 635 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 80,184 KB
最終ジャッジ日時 2023-09-05 01:01:36
合計ジャッジ時間 3,419 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,176 KB
testcase_01 AC 72 ms
71,552 KB
testcase_02 RE -
testcase_03 AC 84 ms
76,296 KB
testcase_04 AC 80 ms
76,420 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 84 ms
76,392 KB
testcase_09 RE -
testcase_10 AC 71 ms
71,340 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 91 ms
76,280 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(N):
    P = []
    for i in range(2,N):
        sieve = 1
        for p in P:
            if p*p > i:
                break
            elif i % p == 0:
                sieve = 0
                break
        if sieve == 0:
            continue
        else:
            P.append(i)
    return P
inpl = lambda: list(map(int,input().split()))
N = int(input())
P = primes(N+1)
dp = [True, True]
for i in range(2, N+1):
    for p in P:
        if p >= i-1:
            dp.append(False)
            break
        elif not dp[i-p]:
            dp.append(True)
            break
if dp[N]:
    print('Win')
else:
    print('Lose')
0