# Project Euler 解答

## Project Euler Problem 091

Project Euler Problem 091

```import Data.List
import Data.Complex

eps :: Double
eps = 1e-6
-- 直角の判定1
isRight :: Complex Double -> Complex Double -> Bool
isRight l r = imp l r
|| imp (r-l) (-l) -- マイナスをつけ忘れてた頭がこんがらがる
|| imp r (r-l)
where imp l r = abs(phase(l/r)-pi/2) Complex Double -> Bool
isRight2 l r =
(((realPart l /= realPart r)||(imagPart l /= imagPart r))
&&
((realPart l /= 0)||(imagPart l /= 0))
&&
((realPart r /= 0)||(imagPart r /= 0))
)
&&
(
(dot l r == 0)
|| (dot (r-l) l == 0)
|| (dot (r-l) r == 0)
)
-- -}
-- z1*z2*cosΘ
dot :: RealFloat a => Complex a -> Complex a -> a
dot x y= realPart \$ ((conjugate x)*y)
-- z1*z2*sinΘ
cross :: RealFloat a => Complex a -> Complex a -> a
cross x y = imagPart \$ ((conjugate x)*y)

r :: [Double]
r = [0..50]
ans1 :: Int
ans1 = length \$ nub \$ sort \$ [((x1,y1),(x2,y2))|
x1 <- r,
x2 <- r,
x1 <= x2,
y1 <- r,
y2 <- r,
y1 >= y2,
isRight2 (x1 :+ y1) (x2 :+ y2)]
-- 14234
main :: IO ()
main = print ans1
```
• はじめに
• プロジェクトオイラー問題
• リンク等