結果

問題 No.7 プライムナンバーゲーム
ユーザー szkhtsszkhts
提出日時 2020-08-22 11:34:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,011 ms / 5,000 ms
コード長 609 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 04:59:16
合計ジャッジ時間 14,706 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 2,009 ms
10,880 KB
testcase_03 AC 153 ms
10,752 KB
testcase_04 AC 58 ms
10,880 KB
testcase_05 AC 61 ms
10,752 KB
testcase_06 AC 624 ms
10,880 KB
testcase_07 AC 426 ms
10,752 KB
testcase_08 AC 199 ms
10,752 KB
testcase_09 AC 910 ms
10,880 KB
testcase_10 AC 29 ms
10,752 KB
testcase_11 AC 433 ms
10,880 KB
testcase_12 AC 1,463 ms
11,008 KB
testcase_13 AC 1,552 ms
10,880 KB
testcase_14 AC 2,011 ms
10,880 KB
testcase_15 AC 1,891 ms
11,008 KB
testcase_16 AC 1,850 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_prime(f):
    prime_list = []

    prime_list.append(2)
    for i in range(3, f + 1, 2):
        isPrime = True
        j = 2
        while j * j <= i:
            if i % j == 0:
                isPrime = False
                break
            j += 1
        if isPrime:
            prime_list.append(i)
        
    return prime_list;

N = int(input())
ar = make_prime(N)

dp = [0 for i in range(N + 1)]
dp[0] = 1
dp[1] = 1
for i in range(2, N + 1):
    for j in ar:
        if i - j < 0:
            break
        dp[i] |= not dp[i - j]
    
if dp[N] == 1:
    print("Win")
else:
    print("Lose")
0