結果

問題 No.7 プライムナンバーゲーム
ユーザー gahougahou
提出日時 2016-11-02 14:12:05
言語 Python2
(2.7.18)
結果
AC  
実行時間 406 ms / 5,000 ms
コード長 420 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 6,700 KB
実行使用メモリ 6,088 KB
最終ジャッジ日時 2023-07-24 20:41:06
合計ジャッジ時間 3,881 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,832 KB
testcase_01 AC 9 ms
5,836 KB
testcase_02 AC 401 ms
6,088 KB
testcase_03 AC 39 ms
6,032 KB
testcase_04 AC 17 ms
6,016 KB
testcase_05 AC 18 ms
5,856 KB
testcase_06 AC 128 ms
5,912 KB
testcase_07 AC 87 ms
5,956 KB
testcase_08 AC 45 ms
5,944 KB
testcase_09 AC 184 ms
5,916 KB
testcase_10 AC 10 ms
6,008 KB
testcase_11 AC 89 ms
6,032 KB
testcase_12 AC 326 ms
5,948 KB
testcase_13 AC 318 ms
5,920 KB
testcase_14 AC 406 ms
6,084 KB
testcase_15 AC 382 ms
5,948 KB
testcase_16 AC 348 ms
5,924 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