結果

問題 No.36 素数が嫌い!
ユーザー aimyaimy
提出日時 2017-06-02 22:03:01
言語 Haskell
(9.8.2)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 602 bytes
コンパイル時間 10,436 ms
コンパイル使用メモリ 168,276 KB
実行使用メモリ 47,284 KB
最終ジャッジ日時 2023-09-09 08:03:20
合計ジャッジ時間 54,007 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,832 ms
30,772 KB
testcase_01 AC 2,342 ms
30,788 KB
testcase_02 AC 3 ms
7,048 KB
testcase_03 AC 3 ms
6,980 KB
testcase_04 AC 2 ms
6,984 KB
testcase_05 AC 6 ms
7,888 KB
testcase_06 AC 7 ms
7,968 KB
testcase_07 AC 6 ms
7,960 KB
testcase_08 AC 3 ms
6,972 KB
testcase_09 AC 2 ms
7,068 KB
testcase_10 AC 5 ms
7,680 KB
testcase_11 AC 1,162 ms
30,472 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 7 ms
7,976 KB
testcase_15 AC 2 ms
7,064 KB
testcase_16 AC 2 ms
6,980 KB
testcase_17 AC 2 ms
6,984 KB
testcase_18 AC 2 ms
6,980 KB
testcase_19 AC 1,462 ms
30,724 KB
testcase_20 TLE -
testcase_21 AC 3,532 ms
47,220 KB
testcase_22 AC 3,683 ms
47,068 KB
testcase_23 AC 1,881 ms
30,688 KB
testcase_24 AC 522 ms
21,380 KB
testcase_25 AC 2,112 ms
30,796 KB
testcase_26 AC 2,612 ms
46,296 KB
testcase_27 AC 4,102 ms
47,188 KB
testcase_28 AC 2,551 ms
46,380 KB
testcase_29 AC 4,849 ms
47,156 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.Bool
import Data.List

primes :: [Int]
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)
   where p' = fromIntegral p

main = readLn >>= putStrLn . bool "NO" "YES" . (>2) . length . factorization
0