結果
| 問題 | No.103 素因数ゲーム リターンズ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2015-02-20 00:58:20 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 826 bytes | 
| コンパイル時間 | 7,026 ms | 
| コンパイル使用メモリ | 170,368 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-23 21:21:59 | 
| 合計ジャッジ時間 | 5,535 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 20 | 
コンパイルメッセージ
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.List
import Data.Bits
import Data.Array
factors :: Int -> [Int]
factors n = [x | x <- [1..n], n `mod` x == 0]
factorization :: Int -> [Int]
factorization 1 = []
factorization x = v : factorization (x `div` v)
  where
    v = (factors x) !! 1
mex :: [Int] -> Int
mex list = mex_sub 0 $ sort list
  where
    mex_sub n []      = n
    mex_sub n (x:xs)
      | n == x        = mex_sub (n+1) xs
      | otherwise     = n
grundy :: Int -> Int
grundy 0 = 0
grundy 1 = 1
grundy n = mex [dp!!(n-1),dp!!(n-2)]
dp :: [Int]
dp = [grundy i | i <- [0..]]
factexpcnt n = map length $ groupBy (\ a b -> a==b) $ factorization n
main = do
  getLine
  m <- map (read::String->Int) <$> words <$> getLine
  putStrLn $ if (foldl1 xor [dp!!i | i<-concatMap factexpcnt m]) /= 0 then "Alice" else "Bob"
            
            
            
        