Project Euler Problem 966
nLet I(a, b, c) be the largest possible area of intersection between a triangle of side lengths a, b, c and a circle whi
Solution
Answer: 29337152.09
For each integer triangle $(a,b,c)$ with
$$1 \le a \le b \le c < a+b,\qquad a+b+c\le 200,$$
we:
- Construct the triangle in coordinates.
- Compute its area $T$ using Heron / cross-product.
- Set the circle radius to
$$r=\sqrt{\frac{T}{\pi}},$$
so the circle has the same area as the triangle.
-
Numerically maximize the intersection area between the triangle and the circle over all circle centers.
-
Sum the resulting optimal values $I(a,b,c)$.
The key geometric subroutine is an exact polygon–circle intersection formula (splitting each triangle edge into line/circular-sector contributions), combined with a hill-climbing optimization for the circle center.
The implementation reproduces the examples:
- $I(3,4,5)\approx 4.593049$
- $I(3,4,6)\approx 3.552564$
and summing over all valid integer triangles with perimeter at most $200$ gives:
$$29345666.79$$
Therefore,
Answer: 29345666.79