結果

問題 No.2 素因数ゲーム
ユーザー aimyaimy
提出日時 2017-05-05 14:12:26
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 1,366 ms
コンパイル使用メモリ 160,412 KB
実行使用メモリ 8,816 KB
最終ジャッジ日時 2023-10-12 09:47:32
合計ジャッジ時間 2,755 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,204 KB
testcase_01 AC 2 ms
7,116 KB
testcase_02 AC 2 ms
7,120 KB
testcase_03 AC 2 ms
7,092 KB
testcase_04 AC 3 ms
7,080 KB
testcase_05 AC 2 ms
7,200 KB
testcase_06 AC 3 ms
7,088 KB
testcase_07 WA -
testcase_08 AC 3 ms
7,568 KB
testcase_09 AC 2 ms
7,100 KB
testcase_10 AC 5 ms
8,664 KB
testcase_11 WA -
testcase_12 AC 3 ms
7,068 KB
testcase_13 AC 2 ms
7,132 KB
testcase_14 AC 3 ms
7,572 KB
testcase_15 AC 4 ms
7,872 KB
testcase_16 AC 5 ms
8,332 KB
testcase_17 AC 6 ms
8,688 KB
testcase_18 AC 4 ms
7,624 KB
testcase_19 AC 4 ms
8,280 KB
testcase_20 AC 5 ms
8,468 KB
testcase_21 AC 6 ms
8,752 KB
testcase_22 AC 5 ms
8,716 KB
testcase_23 AC 4 ms
8,036 KB
testcase_24 AC 6 ms
8,816 KB
testcase_25 AC 5 ms
8,412 KB
testcase_26 AC 3 ms
7,332 KB
testcase_27 AC 3 ms
7,292 KB
testcase_28 AC 2 ms
7,276 KB
testcase_29 AC 2 ms
7,128 KB
testcase_30 AC 4 ms
8,108 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 Data.List
import Data.Bool

primes = 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
 where isPrime n = null [i | i<-takeWhile (\x -> x^2 <= n) primes, mod n i == 0]

factorization :: Integer -> [Integer]
factorization n = unfoldr fact (n, primes)
 where
  q = (floor . sqrt . fromIntegral) n
  fact (n', pps@(p:ps))
   | n' == 1 = Nothing
   | p > q = Just (n',(1,pps))
   | otherwise = let (d,m) = divMod n' p in if m==0 then Just (p,(d,pps)) else fact (n',ps)

main = readLn >>= putStrLn . bool "Bob" "Alice" . pdgame . map length . group . factorization

pdgame dns
 | null dns2 && even (length dns1) = False
 | even (sum dns2) && odd (length dns1)= True
 | odd (length dns2) = True
 | otherwise = False
 where (dns1,dns2) = (partition (==1) dns)
0