結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | ducktail |
提出日時 | 2018-06-07 17:42:58 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 184 ms / 5,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 4,926 ms |
コンパイル使用メモリ | 201,280 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-04-09 04:29:09 |
合計ジャッジ時間 | 6,151 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 183 ms
10,264 KB |
testcase_03 | AC | 16 ms
10,112 KB |
testcase_04 | AC | 7 ms
9,984 KB |
testcase_05 | AC | 8 ms
11,008 KB |
testcase_06 | AC | 54 ms
10,068 KB |
testcase_07 | AC | 39 ms
10,044 KB |
testcase_08 | AC | 19 ms
10,076 KB |
testcase_09 | AC | 79 ms
9,196 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 38 ms
9,940 KB |
testcase_12 | AC | 131 ms
9,936 KB |
testcase_13 | AC | 139 ms
9,948 KB |
testcase_14 | AC | 184 ms
10,136 KB |
testcase_15 | AC | 176 ms
10,116 KB |
testcase_16 | AC | 160 ms
10,148 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Control.Applicative ((<$>)) import Data.Bool (bool) import Data.List (unfoldr, foldl') import Data.Vector (Vector, (!), (//)) import qualified Data.Vector as V main :: IO () main = solve <$> readLn >>= putStrLn solve :: Int -> String solve n = bool "Lose" "Win" (dp ! n) where dp = foldl' f (V.replicate (n+1) True) [2 .. n] where f v x = let b = bool True False . and . map ((dp !) . (x -)) . takeWhile (<= x) $ primes in v // [(x, b)] primes :: [Int] primes = 2 : 3 : 5 : 7 : unfoldr f 11 where f x | isP x = Just (x, x+2) | otherwise = f (x+2) isP x = all ((/=0) . (mod x)) . takeWhile ((<= x) . (^ 2)) $ primes