結果

問題 No.106 素数が嫌い!2
ユーザー aimyaimy
提出日時 2017-04-22 23:30:58
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 640 bytes
コンパイル時間 2,066 ms
コンパイル使用メモリ 160,568 KB
実行使用メモリ 14,988 KB
最終ジャッジ日時 2023-09-28 21:47:16
合計ジャッジ時間 14,728 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

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]

isPrime x = null [y | y<-[2..floor (sqrt (fromIntegral x))], mod x y == 0]

factorization n = unfoldr fact (n, primes)
 where
  q = (floor . sqrt . fromIntegral) n
  fact (n', pps@(p:ps))
   | n' == 1 = Nothing
   | isPrime n' = 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 = getLine >>= print . hatep . map read . words

hatep [n,k] = length $ filter (\x -> length (group (factorization x)) >= k) [2..n]
0