結果

問題 No.36 素数が嫌い!
ユーザー aimyaimy
提出日時 2017-06-02 21:55:17
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 2,664 ms
コンパイル使用メモリ 163,188 KB
実行使用メモリ 21,416 KB
最終ジャッジ日時 2023-10-21 20:52:54
合計ジャッジ時間 25,118 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 743 ms
16,100 KB
testcase_01 AC 1,443 ms
21,392 KB
testcase_02 AC 2 ms
5,236 KB
testcase_03 AC 3 ms
5,236 KB
testcase_04 AC 2 ms
5,236 KB
testcase_05 AC 5 ms
6,352 KB
testcase_06 AC 5 ms
6,480 KB
testcase_07 AC 5 ms
6,500 KB
testcase_08 AC 2 ms
5,240 KB
testcase_09 AC 2 ms
5,240 KB
testcase_10 AC 5 ms
6,064 KB
testcase_11 AC 472 ms
13,224 KB
testcase_12 AC 2,003 ms
21,416 KB
testcase_13 AC 2,043 ms
21,416 KB
testcase_14 AC 22 ms
9,436 KB
testcase_15 WA -
testcase_16 AC 2 ms
5,236 KB
testcase_17 AC 2 ms
5,108 KB
testcase_18 AC 2 ms
5,240 KB
testcase_19 AC 612 ms
15,992 KB
testcase_20 AC 2,023 ms
21,416 KB
testcase_21 AC 1,442 ms
21,296 KB
testcase_22 AC 1,512 ms
21,416 KB
testcase_23 AC 782 ms
16,160 KB
testcase_24 WA -
testcase_25 AC 883 ms
16,296 KB
testcase_26 AC 1,073 ms
16,296 KB
testcase_27 AC 1,703 ms
21,416 KB
testcase_28 AC 1,043 ms
16,296 KB
testcase_29 AC 1,973 ms
21,416 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.Bool
import Data.List

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 . (/ 4) . 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 "NO" "YES" . (>2) . length . factorization
0