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.

        static void Main(string[] args)
        {
            int a,b,c;
            for (c = 710; c >= 1; c--)
            {
                for (b = c-1; b >= 1; b--)
                {
                   a = 1000-c-b;
                   if (a>0 && a<b && c * c == a * a +b * b )
                   {
                       Console.WriteLine("result:{0}",a*b*c);
                       Console.ReadLine();
                   }
                }
            }
        }

结果:31875000

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-06-25
  • 2021-07-22
猜你喜欢
相关资源
相似解决方案