結果

問題 No.36 素数が嫌い!
ユーザー 情報学生情報学生
提出日時 2019-08-27 12:35:43
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 2,378 ms
コンパイル使用メモリ 170,496 KB
実行使用メモリ 53,120 KB
最終ジャッジ日時 2024-04-26 17:58:31
合計ジャッジ時間 11,273 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 505 ms
52,992 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 190 ms
22,144 KB
testcase_12 AC 651 ms
52,864 KB
testcase_13 AC 658 ms
52,992 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 344 ms
33,024 KB
testcase_25 WA -
testcase_26 AC 382 ms
33,536 KB
testcase_27 AC 560 ms
52,864 KB
testcase_28 AC 389 ms
33,408 KB
testcase_29 AC 645 ms
52,992 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

main :: IO ()
main = (readLn :: IO Int) >>= putStrLn . solve

solve :: Int -> String
solve n = if y >= 3 then "YES" else "NO"
    where
        x = sqrt $ (fromIntegral n) :: Double
        y = length $ filter (\a -> n `mod` a == 0) $ takeWhile (<= ceiling x) primes

primes :: Integral a => [a]
primes = map fromIntegral $ [2, 3] ++ primes'
    where
        primes' = [5] ++ f 1 7 primes'
        f m s (p:ps) = [n | n <- ns, gcd m n == 1] ++ f (m * p) (p * p) ps
            where
                ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]]
0