結果

問題 No.7 プライムナンバーゲーム
ユーザー tnodinotnodino
提出日時 2022-01-30 17:45:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 5,000 ms
コード長 576 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 82,328 KB
実行使用メモリ 65,580 KB
最終ジャッジ日時 2024-04-09 05:07:06
合計ジャッジ時間 2,426 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,996 KB
testcase_01 AC 36 ms
52,592 KB
testcase_02 AC 141 ms
65,580 KB
testcase_03 AC 56 ms
62,916 KB
testcase_04 AC 49 ms
62,696 KB
testcase_05 AC 48 ms
62,088 KB
testcase_06 AC 76 ms
64,884 KB
testcase_07 AC 69 ms
64,612 KB
testcase_08 AC 59 ms
64,916 KB
testcase_09 AC 90 ms
64,576 KB
testcase_10 AC 37 ms
52,688 KB
testcase_11 AC 67 ms
63,996 KB
testcase_12 AC 116 ms
65,064 KB
testcase_13 AC 118 ms
65,192 KB
testcase_14 AC 139 ms
65,528 KB
testcase_15 AC 135 ms
65,444 KB
testcase_16 AC 128 ms
65,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def SieveofEratosthenes(N):
    P = [0] * (N+1)
    for i in range(2,N+1):
        if P[i] == 0:
            k = i
            while k <= N:
                P[k] = i
                k += i
            P[i] = 0
    return P

N = int(input())
P = SieveofEratosthenes(N)
C = []
for i in range(2,N+1):
    if P[i] == 0:
        C.append(i)
M = len(C)
WL = ['Win'] * (N+1)
for i in range(2,N+1):
    S = set()
    for k in range(M):
        if i - C[k] >= 0:
            S.add(WL[i-C[k]])
        else:
            break
    if not 'Lose' in S:
        WL[i] = 'Lose'
print(WL[N])
0