結果

問題 No.7 プライムナンバーゲーム
ユーザー tomiyancetomiyance
提出日時 2019-11-19 23:28:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,790 ms / 5,000 ms
コード長 436 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-09 04:46:01
合計ジャッジ時間 13,182 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 1,790 ms
11,264 KB
testcase_03 AC 140 ms
10,880 KB
testcase_04 AC 59 ms
10,880 KB
testcase_05 AC 57 ms
10,752 KB
testcase_06 AC 529 ms
11,008 KB
testcase_07 AC 380 ms
10,880 KB
testcase_08 AC 182 ms
11,008 KB
testcase_09 AC 819 ms
11,008 KB
testcase_10 AC 29 ms
10,880 KB
testcase_11 AC 374 ms
11,008 KB
testcase_12 AC 1,281 ms
11,136 KB
testcase_13 AC 1,369 ms
11,136 KB
testcase_14 AC 1,782 ms
11,264 KB
testcase_15 AC 1,701 ms
11,264 KB
testcase_16 AC 1,554 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
def get_sieve_of_eratosthenes(n):
  data = [i for i in range(2, n + 1)]
  for d in data:
    data = [x for x in data if (x == d or x % d != 0)]
  return data

is_win = [0] * (N+1)
is_win[0] = 1
is_win[1] = 1
data = get_sieve_of_eratosthenes(N)
for i in range(2,N+1):
  for j in [x for x in data if x <= i]:
    if not is_win[i - j]:
      is_win[i] = 1
      break
if is_win[N]:
    print('Win')
else:
    print('Lose')
0