結果

問題 No.7 プライムナンバーゲーム
ユーザー MaboyMaboy
提出日時 2017-04-22 11:59:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 339 ms / 5,000 ms
コード長 384 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-09 04:13:11
合計ジャッジ時間 3,186 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 339 ms
11,392 KB
testcase_03 AC 50 ms
11,008 KB
testcase_04 AC 34 ms
10,880 KB
testcase_05 AC 34 ms
10,880 KB
testcase_06 AC 109 ms
11,136 KB
testcase_07 AC 85 ms
11,008 KB
testcase_08 AC 56 ms
10,880 KB
testcase_09 AC 149 ms
11,264 KB
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 86 ms
10,880 KB
testcase_12 AC 220 ms
11,136 KB
testcase_13 AC 229 ms
11,264 KB
testcase_14 AC 326 ms
11,520 KB
testcase_15 AC 273 ms
11,392 KB
testcase_16 AC 261 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def PN(n):
  i=1
  L=[i for i in range(n+1)]
  while i < n**0.5:
    i+=1
    if i in L:
      L=[x if x%i!=0 else 0 for x in L]
      L[i]=i
  L=set(L)
  L^=set([0,1])
  return L

def G(N):
  P=PN(N)
  L=set([])
  for i in range(2,N+1):
    f=0
    for j in P:
      if (i-j) in L:
        f=1;break
    if f==0:
      L.add(i)
  print("Lose" if N in L else "Win")
  
G(int(input()))
0