結果

問題 No.2 素因数ゲーム
ユーザー aimyaimy
提出日時 2017-05-04 12:30:15
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 162,248 KB
実行使用メモリ 8,832 KB
最終ジャッジ日時 2023-10-12 07:54:29
合計ジャッジ時間 2,219 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,148 KB
testcase_01 WA -
testcase_02 AC 3 ms
7,120 KB
testcase_03 AC 3 ms
7,100 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
7,200 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 5 ms
8,132 KB
testcase_12 AC 2 ms
7,108 KB
testcase_13 WA -
testcase_14 AC 3 ms
7,436 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 6 ms
8,632 KB
testcase_18 AC 3 ms
7,596 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
7,392 KB
testcase_27 AC 3 ms
7,396 KB
testcase_28 WA -
testcase_29 AC 2 ms
7,120 KB
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
 | odd (length dns) && even (length (filter (>1) dns)) = False
 | otherwise = True
0