eBash

It is not the mountain we conquer but ourselves

Project Euler Problem 9

| Comments

Table of Contents

1 Problem

A Pythagorean triplet is a set of three natural numbers, a b c, for which,

a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc.

2 Solution

很直接

假设 \(a \leqslant b \leqslant c\) ,则

\begin{eqnarray} a \leqslant \frac{s-3}{3} \end{eqnarray} \begin{eqnarray} b < \frac{s-a}{2} \end{eqnarray}

3 Answer

31875000

Source:C++

Comments