結果

問題 No.36 素数が嫌い!
ユーザー aimyaimy
提出日時 2017-06-02 21:40:54
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 350 bytes
コンパイル時間 4,967 ms
コンパイル使用メモリ 165,904 KB
実行使用メモリ 50,056 KB
最終ジャッジ日時 2023-10-21 20:51:50
合計ジャッジ時間 16,487 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,184 KB
testcase_01 AC 2 ms
5,188 KB
testcase_02 AC 2 ms
5,116 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 6 ms
5,956 KB
testcase_08 AC 2 ms
5,184 KB
testcase_09 AC 3 ms
5,184 KB
testcase_10 AC 2 ms
5,184 KB
testcase_11 AC 1,162 ms
21,384 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 6 ms
5,992 KB
testcase_15 AC 3 ms
5,180 KB
testcase_16 AC 2 ms
5,116 KB
testcase_17 AC 2 ms
5,116 KB
testcase_18 AC 2 ms
5,184 KB
testcase_19 AC 2 ms
5,184 KB
testcase_20 AC 2 ms
5,184 KB
testcase_21 AC 2 ms
5,184 KB
testcase_22 AC 2 ms
5,184 KB
testcase_23 AC 3 ms
5,184 KB
testcase_24 AC 2 ms
5,184 KB
testcase_25 AC 2 ms
5,184 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/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*x <= n) primes, mod n i == 0]

main = readLn >>= putStrLn . bool "NO" "YES" . (\x -> any (\p -> mod x p == 0) (takeWhile (<= (sq x)) primes))
 where sq = floor . sqrt . fromIntegral
0