結果

問題 No.7 プライムナンバーゲーム
ユーザー konchanksukonchanksu
提出日時 2020-04-29 01:35:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 436 ms / 5,000 ms
コード長 557 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-09 04:51:59
合計ジャッジ時間 4,206 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 436 ms
11,264 KB
testcase_03 AC 55 ms
10,880 KB
testcase_04 AC 36 ms
10,752 KB
testcase_05 AC 36 ms
10,880 KB
testcase_06 AC 153 ms
11,136 KB
testcase_07 AC 113 ms
11,008 KB
testcase_08 AC 63 ms
10,880 KB
testcase_09 AC 211 ms
11,008 KB
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 113 ms
11,008 KB
testcase_12 AC 316 ms
11,264 KB
testcase_13 AC 320 ms
11,264 KB
testcase_14 AC 418 ms
11,264 KB
testcase_15 AC 388 ms
11,264 KB
testcase_16 AC 374 ms
11,264 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