結果

問題 No.7 プライムナンバーゲーム
ユーザー naesiranaesira
提出日時 2023-11-22 12:59:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 64,780 KB
最終ジャッジ日時 2023-11-22 12:59:42
合計ジャッジ時間 2,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 51 ms
64,780 KB
testcase_03 WA -
testcase_04 AC 46 ms
60,032 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 50 ms
62,256 KB
testcase_08 AC 48 ms
62,260 KB
testcase_09 AC 50 ms
62,232 KB
testcase_10 WA -
testcase_11 AC 49 ms
62,256 KB
testcase_12 AC 55 ms
64,468 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 50 ms
64,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

primes = set(range(2, N+1))
for i in range(2, N+1):
  if i not in primes: continue
  for j in range(2*i, N+1):
    primes.discard(j)
primes = sorted(primes)

dp = ["Win"]*2 + ["Lose"]*(N-1)
for i in range(2, N+1):
  for d in primes:
    if i < d: break
    if dp[i-d] == "Lose":
      dp[i] = "Win"
      break

print(dp[N])
0