結果

問題 No.106 素数が嫌い!2
ユーザー aimyaimy
提出日時 2017-04-22 23:37:41
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 636 bytes
コンパイル時間 6,581 ms
コンパイル使用メモリ 163,012 KB
実行使用メモリ 11,212 KB
最終ジャッジ日時 2023-09-28 21:47:36
合計ジャッジ時間 2,674 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
11,092 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 3 ms
6,888 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 92 ms
11,016 KB
testcase_08 WA -
testcase_09 AC 12 ms
11,072 KB
testcase_10 AC 92 ms
10,956 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,824 KB
testcase_14 AC 3 ms
6,840 KB
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
   | n' > 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 = getLine >>= print . hatep . map read . words

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