fork download
  1. -- author: Leonardne @ NEETSDKASU
  2.  
  3. import qualified Data.IntSet as IS
  4.  
  5. hoge p = [p,p+p..]
  6.  
  7. fuga p = unzip . map (break (> p))
  8.  
  9. piyo (s, e, xs) =
  10. case IS.minView s of
  11. Nothing -> piyo $ foo e xs
  12. Just (p, t) -> p : piyo (bar p t e xs)
  13.  
  14. foo e xs = (t, r, ys)
  15. where
  16. r = e+100000
  17. s = IS.fromList [e+2,e+4..r]
  18. (d, ys) = fuga r xs
  19. t = foldl (foldl (flip IS.delete)) s d
  20.  
  21. bar p s e xs = (t, e, ys)
  22. where
  23. (d, ps) = break (> e) $ hoge p
  24. t = foldl (flip IS.delete) s d
  25. ys = ps:xs
  26.  
  27. baz = 2 : 3 : piyo (IS.empty, 3, [hoge 3])
  28.  
  29.  
  30. main = print $ take 100 $ drop 99950 $ baz
  31.  
Success #stdin #stdout 1.11s 0KB
stdin
Standard input is empty
stdout
[1299019,1299029,1299041,1299059,1299061,1299079,1299097,1299101,1299143,1299169,1299173,1299187,1299203,1299209,1299211,1299223,1299227,1299257,1299269,1299283,1299289,1299299,1299317,1299323,1299341,1299343,1299349,1299359,1299367,1299377,1299379,1299437,1299439,1299449,1299451,1299457,1299491,1299499,1299533,1299541,1299553,1299583,1299601,1299631,1299637,1299647,1299653,1299673,1299689,1299709,1299721,1299743,1299763,1299791,1299811,1299817,1299821,1299827,1299833,1299841,1299853,1299869,1299877,1299887,1299899,1299917,1299919,1299941,1299953,1299979,1299989,1300021,1300027,1300031,1300051,1300073,1300097,1300111,1300127,1300129,1300133,1300139,1300141,1300147,1300153,1300181,1300193,1300199,1300237,1300253,1300283,1300289,1300297,1300307,1300309,1300319,1300333,1300339,1300367,1300391]