結果

問題 No.7 プライムナンバーゲーム
ユーザー nuwasoginuwasogi
提出日時 2015-11-24 16:16:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,595 ms / 5,000 ms
コード長 806 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-09 03:52:35
合計ジャッジ時間 11,868 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 1,563 ms
11,008 KB
testcase_03 AC 128 ms
10,880 KB
testcase_04 AC 56 ms
10,752 KB
testcase_05 AC 55 ms
10,752 KB
testcase_06 AC 493 ms
11,136 KB
testcase_07 AC 328 ms
10,880 KB
testcase_08 AC 165 ms
10,880 KB
testcase_09 AC 721 ms
10,880 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 339 ms
10,880 KB
testcase_12 AC 1,124 ms
11,008 KB
testcase_13 AC 1,199 ms
11,008 KB
testcase_14 AC 1,595 ms
11,008 KB
testcase_15 AC 1,495 ms
11,008 KB
testcase_16 AC 1,363 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False
# return prime list where less than n
def sieve(n):
    s = [True] * n
    for x in range(2, int(n ** 0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

if __name__ == "__main__":
    N = int(input())
    if N <= 3:
        print("Lose")
    else:
        slist = sieve(N - 1)
        WLList = [False] * (N+1)
        checkList = []
        for x in range(4, N+1):
            if x-2 in slist:
                checkList.append(x-2)
            checkList2 = list(map(lambda p : x-p, checkList))
            for y in checkList2:
                if WLList[y] == False:
                    WLList[x] = True
        if WLList[N]:
            print("Win")
        else:
            print("Lose")
0