We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #9: Special Pythagorean triplet
Project Euler #9: Special Pythagorean triplet
Sort by
recency
|
168 Discussions
|
Please Login in order to post a comment
We know that
c = n - a - b
But also we know that
a^2 + b^2 = c^2
So after substutions we can calculate relation between
a
andb
given thatn=const.
So we can substitute everything into
a*b*c
and get some complicated function. After some more math magic on paper I've came up with neat solution. It's guaranteed that the first solution is already the best one.Do they want the primitive triplet or the triplet multiplied by the factor n/(a+b+c)
Maybe it can still be optimized:
C# code :
using System;
public class Solution { public static void Main(string[] args) { int t = Convert.ToInt32(Console.ReadLine());
}