Project Euler Problem 075
import Data.List import qualified Data.Map as M d :: Integer d=1500000 :: Integer mapper :: Ord k => [k] -> Int mapper l= M.size $ M.filter(==1) $ foldl' (\a c -> M.insertWith (+) c 1 a) M.empty l ans1 :: Int ans1 = mapper lis where lis = [ k*l | m<-[2..ul],n<-[1..m], gcd m n==1, odd (m+n), --既約ピタゴラス数生成 let l=2*m*(m+n), --ここから、mは(sqrt (d/2))までで良い k<-[1..(d`quot`l)]] -- k<-[1..d],k*l<=d相当 ul = ((ceiling (sqrt $ fromIntegral (d`quot`2)))) --2m(m+n)からの枝かり main :: IO () main = print ans1