码迷,mamicode.com
首页 > 其他好文 > 详细

Special Pythagorean triplet

时间:2014-05-09 10:35:46      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   ext   color   

这个比较简单,慢慢进入状态。

A Pythagorean triplet is a set of three natural numbers, a bubuko.com,布布扣 b bubuko.com,布布扣 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.

for a in xrange(1,1000):
    for b in xrange(1,1000):
        c = 1000 - (a + b)
        if (c * c) == (a * a + b * b):
            print a * b * c
            break

31875000
31875000
请按任意键继续. . .

Special Pythagorean triplet,布布扣,bubuko.com

Special Pythagorean triplet

标签:style   blog   class   code   ext   color   

原文地址:http://www.cnblogs.com/aguncn/p/3715993.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!