結果

問題 No.103 素因数ゲーム リターンズ
ユーザー gigurururugigurururu
提出日時 2015-02-20 00:58:20
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 164,548 KB
実行使用メモリ 8,336 KB
最終ジャッジ日時 2023-09-06 02:26:27
合計ジャッジ時間 2,884 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,364 KB
testcase_01 AC 2 ms
7,348 KB
testcase_02 AC 2 ms
7,352 KB
testcase_03 AC 2 ms
7,404 KB
testcase_04 AC 2 ms
7,368 KB
testcase_05 AC 2 ms
7,176 KB
testcase_06 AC 2 ms
7,432 KB
testcase_07 AC 2 ms
7,128 KB
testcase_08 AC 2 ms
7,048 KB
testcase_09 AC 2 ms
7,116 KB
testcase_10 AC 3 ms
7,404 KB
testcase_11 AC 3 ms
7,624 KB
testcase_12 AC 3 ms
7,720 KB
testcase_13 AC 4 ms
7,668 KB
testcase_14 AC 3 ms
7,824 KB
testcase_15 AC 4 ms
7,816 KB
testcase_16 AC 2 ms
7,456 KB
testcase_17 AC 3 ms
7,828 KB
testcase_18 AC 3 ms
7,504 KB
testcase_19 AC 4 ms
7,956 KB
testcase_20 AC 3 ms
7,564 KB
testcase_21 AC 3 ms
7,716 KB
testcase_22 AC 3 ms
7,556 KB
testcase_23 AC 3 ms
7,612 KB
testcase_24 AC 3 ms
8,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

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"
0