結果

問題 No.106 素数が嫌い!2
ユーザー ducktailducktail
提出日時 2018-05-21 15:23:06
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 446 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 167,724 KB
実行使用メモリ 9,636 KB
最終ジャッジ日時 2023-09-11 00:21:04
合計ジャッジ時間 16,144 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,802 ms
7,192 KB
testcase_01 AC 3 ms
7,188 KB
testcase_02 AC 2 ms
7,180 KB
testcase_03 AC 3 ms
7,164 KB
testcase_04 AC 2,792 ms
7,060 KB
testcase_05 TLE -
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 Control.Applicative ((<$>))

main :: IO ()
main = solve <$> map read <$> words <$> getLine >>= print

solve :: [Int] -> Int
solve [n, k] = length . filter (f k 0 2) $ [2..n]
  where f k c d x | x == 1 = c >= k
                  | x `mod` d == 0 = f k (c+1) (d+1) (g d x)
                  | d ^ 2 > x = c + 1 >= k
                  | otherwise = f k c (d+1) x
        g d x | x `mod` d == 0 = g d (x `div` d)
              | otherwise = x
0