結果

問題 No.7 プライムナンバーゲーム
ユーザー konchanksukonchanksu
提出日時 2020-04-29 01:35:21
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 387 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 8,908 KB
最終ジャッジ日時 2023-07-24 21:33:37
合計ジャッジ時間 3,569 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,900 KB
testcase_01 AC 14 ms
7,796 KB
testcase_02 AC 387 ms
8,860 KB
testcase_03 AC 35 ms
8,516 KB
testcase_04 AC 21 ms
7,820 KB
testcase_05 AC 19 ms
7,868 KB
testcase_06 AC 126 ms
8,692 KB
testcase_07 AC 89 ms
8,720 KB
testcase_08 AC 45 ms
8,264 KB
testcase_09 AC 157 ms
8,840 KB
testcase_10 AC 13 ms
7,796 KB
testcase_11 AC 78 ms
8,448 KB
testcase_12 AC 254 ms
8,740 KB
testcase_13 AC 295 ms
8,748 KB
testcase_14 AC 339 ms
8,864 KB
testcase_15 AC 369 ms
8,836 KB
testcase_16 AC 297 ms
8,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

def prime_num(end):
    lists = [i for i in range(2, end + 1)]
    ans = []
    while True:
        if lists[0] > end ** 0.5:
            break
        ans.append(lists[0])
        lists = list(filter(lambda x:x % lists[0], lists))
        
    return ans + lists
    
dp = [False for i in range(N + 1)] 
prime = prime_num(N)
dp[0], dp[1] = True, True

for i in range(2, N + 1):
    for j in prime:
        if j > i:
            break
        if not dp[i - j]:
            dp[i] = True
            break

print('Win' if dp[N] else 'Lose')
0