結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | Leonardone |
提出日時 | 2015-11-04 16:05:47 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,071 bytes |
コンパイル時間 | 3,073 ms |
コンパイル使用メモリ | 163,384 KB |
実行使用メモリ | 7,612 KB |
最終ジャッジ日時 | 2023-10-11 13:41:30 |
合計ジャッジ時間 | 10,065 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,612 KB |
testcase_01 | WA | - |
testcase_02 | TLE | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU -- http://yukicoder.me/problems/25 -- 解説読んだ後 import Data.List import qualified Data.Set as Set main = do n <- readLn putStrLn $ solve n solve n = let p = pn n s = Set.fromAscList [0,1] r = resultMap p [2..n] s in if Set.member n r then "Win" else "Lose" resultMap _ [] s = s resultMap p (x:xs) s = let f _ [] s = s f x (p:ps) s | v < 0 = s | Set.notMember v s = f x ps $ Set.insert x s | otherwise = f x ps s where v = x - p ss = f x p s in resultMap p xs ss primeNumbers n = f [2..n] where f [] = [] f (x:xs) = x : f [z | z <- xs, (z `mod` x) > 0] pn n = f n [2..n] [] Set.empty where f _ [] ls _ = reverse ls f n (x:xs) ls s | Set.member x s = f n xs ls s | otherwise = f n xs (x:ls) $ foldl (\s x -> Set.insert x s) s [y * x | y <- [2..(n `mod` x)]]