結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-13 04:10:39 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 314 ms / 5,000 ms |
| コード長 | 544 bytes |
| コンパイル時間 | 310 ms |
| コンパイル使用メモリ | 6,912 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-10-01 16:13:40 |
| 合計ジャッジ時間 | 4,594 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
def mark(s, x):
for i in xrange(x + x, len(s), x):
s[i] = False
def sieve(n):
s = [True] * n
for x in xrange(2, int(n**0.5) + 1):
if s[x]: mark(s, x)
return [i for i in xrange(0,n) if s[i] and i > 1]
n = int(input())
primes = sieve(n+2)
game = ['L' for i in range(10**4+10)]
game[2] = 'L'
game[3] = 'L'
i = 2
while i < len(game):
if game[i] == 'L':
t = 0
while t < len(primes) and i + primes[t] < len(game) :
game[i + primes[t]] = 'W'
t += 1
i += 1
print 'Win' if game[n] == 'W' else 'Lose'