結果

問題 No.2 素因数ゲーム
ユーザー aimyaimy
提出日時 2017-05-05 13:41:25
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 2,512 ms
コンパイル使用メモリ 161,864 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2023-10-12 09:47:07
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,052 KB
testcase_01 AC 3 ms
7,036 KB
testcase_02 AC 3 ms
7,064 KB
testcase_03 AC 3 ms
7,088 KB
testcase_04 AC 3 ms
7,120 KB
testcase_05 AC 2 ms
7,124 KB
testcase_06 AC 2 ms
7,144 KB
testcase_07 WA -
testcase_08 AC 4 ms
7,620 KB
testcase_09 AC 3 ms
7,124 KB
testcase_10 AC 6 ms
8,628 KB
testcase_11 WA -
testcase_12 AC 2 ms
7,044 KB
testcase_13 WA -
testcase_14 AC 4 ms
7,504 KB
testcase_15 AC 4 ms
7,932 KB
testcase_16 AC 5 ms
8,320 KB
testcase_17 AC 6 ms
8,684 KB
testcase_18 AC 3 ms
7,620 KB
testcase_19 AC 5 ms
8,288 KB
testcase_20 AC 5 ms
8,408 KB
testcase_21 AC 6 ms
8,716 KB
testcase_22 WA -
testcase_23 AC 4 ms
8,152 KB
testcase_24 AC 6 ms
8,720 KB
testcase_25 AC 5 ms
8,456 KB
testcase_26 AC 3 ms
7,404 KB
testcase_27 AC 3 ms
7,316 KB
testcase_28 AC 2 ms
7,164 KB
testcase_29 AC 2 ms
7,128 KB
testcase_30 AC 4 ms
8,064 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 && odd (length dns1) = True
 | odd (length dns2) = True
 | otherwise = False
 where (dns1,dns2) = (partition (==1) dns)
0