This is essentially the same as: Problem 52834. Easy Sequences 32: Almost Pythagorean Triples; it even presents the same set of test problems. The difference is that the "correct" solutions for larger cases of 52834 were the result of roundoff errors due to values being larger than flintmax('double'). This problem requires care to avoid such roundoff.
Repeating the original problem description:
An Almost Pythagorean Triple (abbreviated as "APT'), is a set of 3 integers in which square of the largest element, which we will call as its 'hypotenuse', is 1 less than the sum of square of the smaller elements (shorter sides). This means that if c is the hypotenuse and a and b are the shorter sides,
, satisfies the following equation:
where: 
The smallest
is the triple
, with
and perimeter (the sum of the 3 elements) of
. Some researchers consider
as the smallest
, but here, we will only look at
's where the hypotenuse is "strictly" greater than the other shorter sides. Other examples of
's are
, and
.
Unfortunately, unlike Pythagorean Triples, a 'closed formula' for generating all possible
's, has not yet been discovered, at the time of this writing. For this exercise, we will be dealing with
's with a known ratio between the hypotenuse and the shortest side:
.
Given the value of r, find the perimeter of the
with the r-th smallest perimeter. For example for
, that is
, the smallest perimeter is
for
, while the second (r-th) smallest perimeter is
, for the
with dimensions
. For
, the third smallest perimeter is
for
.
The output can be very large, so please present only the last 12 digits if the number of digits of the perimeter exceeds 12.
Finally, as with the original, the use of java, BigInteger, persistent, and global are not allowed.
Solution Stats
Problem Comments
1 Comment
Solution Comments
Show comments
Loading...
Problem Recent Solvers0
No solvers yet, be the first player to solve this problem.
Suggested Problems
-
Precise Almost Pythagorean Triples
0 Solvers
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Some of the test cases contradict the problem statement in that the amount of digits in the "correct" answer is sometimes more than 12. Also, the digits beyond the 12th digit in said answers appear to be incorrect.