結果

問題 No.7 プライムナンバーゲーム
ユーザー AtamaokaCAtamaokaC
提出日時 2021-06-19 17:11:05
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 670 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 86,812 KB
実行使用メモリ 76,372 KB
最終ジャッジ日時 2023-07-24 21:47:00
合計ジャッジ時間 2,717 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,088 KB
testcase_01 AC 73 ms
71,356 KB
testcase_02 AC 95 ms
76,220 KB
testcase_03 AC 84 ms
76,216 KB
testcase_04 AC 82 ms
75,940 KB
testcase_05 AC 80 ms
75,876 KB
testcase_06 AC 87 ms
76,372 KB
testcase_07 AC 87 ms
76,200 KB
testcase_08 AC 85 ms
76,280 KB
testcase_09 AC 89 ms
76,232 KB
testcase_10 AC 73 ms
71,124 KB
testcase_11 AC 86 ms
76,296 KB
testcase_12 AC 92 ms
76,144 KB
testcase_13 AC 92 ms
75,964 KB
testcase_14 AC 94 ms
75,984 KB
testcase_15 AC 92 ms
75,912 KB
testcase_16 AC 92 ms
76,196 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