結果

問題 No.7 プライムナンバーゲーム
ユーザー gahougahou
提出日時 2016-11-02 14:12:05
言語 Python2
(2.7.18)
結果
AC  
実行時間 508 ms / 5,000 ms
コード長 420 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 7,080 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 04:04:22
合計ジャッジ時間 4,696 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,820 KB
testcase_01 AC 11 ms
6,948 KB
testcase_02 AC 508 ms
6,948 KB
testcase_03 AC 43 ms
6,948 KB
testcase_04 AC 21 ms
6,944 KB
testcase_05 AC 20 ms
6,944 KB
testcase_06 AC 158 ms
6,948 KB
testcase_07 AC 110 ms
6,944 KB
testcase_08 AC 56 ms
6,944 KB
testcase_09 AC 233 ms
6,948 KB
testcase_10 AC 11 ms
6,944 KB
testcase_11 AC 111 ms
6,944 KB
testcase_12 AC 367 ms
6,944 KB
testcase_13 AC 387 ms
6,948 KB
testcase_14 AC 506 ms
6,944 KB
testcase_15 AC 481 ms
6,944 KB
testcase_16 AC 443 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
  lst = [2]
  for i in xrange(3, n+1):
    for j in xrange(len(lst)):
      if i%lst[j]==0: break
      if i<=lst[j]**2:
        lst.append(i)
        break
  return lst

n = int(raw_input())
p = primes(n)
dp = [0] * (n+1)
dp[0]=1
dp[1]=1
for i in xrange(2, n+1):
  for j in xrange(len(p)):
    if i < p[j]: break
    if dp[i-p[j]]==0:
      dp[i]=1
      break
if dp[n]==0: print "Lose"
else: print "Win"
0