Chinaunix首页 | 论坛 | 博客
  • 博客访问: 86574
  • 博文数量: 47
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 625
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-11 12:11
文章分类

全部博文(47)

文章存档

2008年(47)

我的朋友

分类:

2008-11-14 16:58:14

Problem 39

14 March 2003

If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.

{20,48,52}, {24,45,51}, {30,40,50}

For which value of p 1000, is the number of solutions maximised?

def fun39():
    result = (0, 0)
    #a**2+b**2=c**2,a<=b
    (a,b,c)=(1,2,3)
    for p in range(4, 1000):
        count = 0
        for a in range(1, p/3):
            t = (a**2)%(p-a)
            if t != 0:
                continue
            else:
                t = (a**2)/(p-a)
                if (t+p-a)%2 == 0:
                    (b,c) = ((p-a-t)/2, (t+p-a)/2)
                    if b < a:
                        break
                    else:
                        count += 1
                        print a,b,c
        if count > result[1]:
            result = (p, count)
    return result

answer is 840, 共有8组
time:0.125
阅读(419) | 评论(0) | 转发(0) |
0

上一篇:Problem 38

下一篇:Problem 41

给主人留下些什么吧!~~