結果
問題 | No.7 プライムナンバーゲーム |
ユーザー |
![]() |
提出日時 | 2016-04-25 03:32:08 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 1,924 ms / 5,000 ms |
コード長 | 400 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 6,912 KB |
最終ジャッジ日時 | 2024-10-01 15:43:39 |
合計ジャッジ時間 | 13,922 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
import math N = int(raw_input()) primes = [] nums = range(2,N+1) while nums: num = nums.pop(0) primes.append(num) if num > math.sqrt(N): primes += nums break else: nums = filter(lambda x:x%num!=0, nums) game = [True, True]+[False for _ in range(N-1)] for i in range(2,N+1): for j in filter(lambda x:x<i+1,primes): if game[i-j] == False: game[i]=True print "Win" if game[-1] else "Lose"