結果
| 問題 |
No.2 素因数ゲーム
|
| ユーザー |
|
| 提出日時 | 2015-03-09 08:02:14 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 662 bytes |
| コンパイル時間 | 5,926 ms |
| コンパイル使用メモリ | 148,608 KB |
| 最終ジャッジ日時 | 2024-12-26 11:03:58 |
| 合計ジャッジ時間 | 6,355 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:5:1: error: [GHC-87110]
Could not load module ‘Data.IntMap’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
5 | import qualified Data.IntMap as IM
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative
import Control.Monad
import Data.List
import Data.Bits
import qualified Data.IntMap as IM
primeVector n = if n'>1 then IM.insertWith (+) n 1 m' else m' where
(n',m') = foldl' go (n, IM.empty) $ takeWhile (\x -> x^2 <= n) [2..]
go (k,m) i
| k `mod` i == 0 = let (q,t) = divAll k i in (q, IM.insertWith (+) i t m)
| otherwise = (k,m)
divAll a b
| a `mod` b == 0 = let (q,t) = divAll (a`div`b) b in (q,t+1)
| otherwise = (a,0)
solve n = if solve' n == 0 then "Bob" else "Alice"
solve' n = foldl' xor (0 :: Int) $ IM.elems $ primeVector n
main = do
n <- (read :: String -> Int) <$> getLine
putStrLn $ solve n