結果

問題 No.7 プライムナンバーゲーム
ユーザー AtamaokaCAtamaokaC
提出日時 2021-06-19 17:11:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 670 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 64,472 KB
最終ジャッジ日時 2024-04-09 05:04:39
合計ジャッジ時間 1,924 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,364 KB
testcase_01 AC 36 ms
52,472 KB
testcase_02 AC 59 ms
64,280 KB
testcase_03 AC 48 ms
63,848 KB
testcase_04 AC 44 ms
62,140 KB
testcase_05 AC 45 ms
60,984 KB
testcase_06 AC 53 ms
63,544 KB
testcase_07 AC 56 ms
63,416 KB
testcase_08 AC 49 ms
62,812 KB
testcase_09 AC 53 ms
63,776 KB
testcase_10 AC 36 ms
52,952 KB
testcase_11 AC 50 ms
62,900 KB
testcase_12 AC 57 ms
64,472 KB
testcase_13 AC 57 ms
63,312 KB
testcase_14 AC 59 ms
64,172 KB
testcase_15 AC 59 ms
63,108 KB
testcase_16 AC 59 ms
63,300 KB
権限があれば一括ダウンロードができます

ソースコード

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
    else:
        dp.append(False)
if dp[N]:
    print('Win')
else:
    print('Lose')
0