結果

問題 No.2 素因数ゲーム
ユーザー aimyaimy
提出日時 2017-05-05 14:16:07
言語 Haskell
(9.8.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 764 bytes
コンパイル時間 3,660 ms
コンパイル使用メモリ 164,068 KB
実行使用メモリ 8,660 KB
最終ジャッジ日時 2023-08-28 15:26:40
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,076 KB
testcase_01 AC 2 ms
7,052 KB
testcase_02 AC 2 ms
7,056 KB
testcase_03 AC 2 ms
7,068 KB
testcase_04 AC 2 ms
7,048 KB
testcase_05 AC 2 ms
7,116 KB
testcase_06 AC 2 ms
7,036 KB
testcase_07 AC 3 ms
7,108 KB
testcase_08 AC 4 ms
7,564 KB
testcase_09 AC 2 ms
6,988 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
7,112 KB
testcase_13 AC 2 ms
7,008 KB
testcase_14 AC 3 ms
7,472 KB
testcase_15 AC 4 ms
7,740 KB
testcase_16 AC 5 ms
8,272 KB
testcase_17 AC 5 ms
8,588 KB
testcase_18 AC 3 ms
7,524 KB
testcase_19 AC 4 ms
8,368 KB
testcase_20 AC 5 ms
8,388 KB
testcase_21 AC 5 ms
8,660 KB
testcase_22 AC 5 ms
8,576 KB
testcase_23 AC 4 ms
8,112 KB
testcase_24 AC 5 ms
8,584 KB
testcase_25 AC 5 ms
8,388 KB
testcase_26 AC 3 ms
7,372 KB
testcase_27 AC 2 ms
7,244 KB
testcase_28 AC 2 ms
7,136 KB
testcase_29 AC 2 ms
7,032 KB
testcase_30 AC 4 ms
8,120 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) && (not.null) dns1 = True
 | odd (length dns2) = True
 | otherwise = False
 where (dns1,dns2) = (partition (==1) dns)
0