TLE,求助

import Control.Monad (forM_, join)

main :: IO ()
main = join $ getLine >>= return . map read . words >>= return . \[m, n] ->
         let p1 = primesBounded n
             p2 = dropWhile (< m) p1
             p3 = filter isPalindromic p2
          in forM_ p3 print

primesBounded :: Integral a => a -> [a]
primesBounded m = 2 : filterPrimes [3, 5..m]
  where filterPrimes all@(x : xs)
          | x > bound = all
          | otherwise = x : filterPrimes (filter (\n -> n `mod` x /= 0) xs)
        bound = floor $ sqrt $ fromIntegral m

isPalindromic :: Show a => a -> Bool
isPalindromic n = let s = show n in s == reverse s

0 条评论

目前还没有评论...

信息

ID
1042
难度
6
分类
搜索 | 搜索与剪枝 点击显示
标签
(无)
递交数
6023
已通过
1419
通过率
24%
上传者