結果

問題 No.7 プライムナンバーゲーム
ユーザー shianoshiano
提出日時 2020-06-23 23:40:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 615 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 8,472 KB
最終ジャッジ日時 2023-09-16 20:20:28
合計ジャッジ時間 1,694 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 19 ms
8,268 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 20 ms
8,344 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 21 ms
8,320 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 20 ms
8,300 KB
testcase_15 AC 20 ms
8,372 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i    
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime,table

n = int(input())

MAX = 10001
dp = [0]*(MAX)
dp[0] = dp[1] = 1

is_prime, table = sieve(10005)

for i in range(2,MAX):
  for p in table:
    if is_prime[p]:
      break
    if dp[i-is_prime[p]]==0:
      dp[i] = 1
               
if dp[n]%2 == 0:
  print('Lose')
else:
  print('Win')
0