Files
test/ProjectEuler/p009_SpecialPythagoreanTriplet.cpp

34 lines
623 B
C++

/* Check cf5-opt.vim defs.
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
*/
#include <iostream>
/*
Special Pythagorean triplet
Problem 9
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
Solution:
*/
int main ( void )
{
// a^2+b^2=c^2=(1000-a-b)^2= 1000^2-2000(a+b)+(a+b)^2=
// = 1000^2-2000(a+b)+a^2+2ab+b^2 =>
// => 0=1000^2-2000(a+b)+2ab =>
// => 500000=1000(a+b)-ab
return 0;
}