搜索
查看: 1510|回复: 2
打印 上一主题 下一主题

挑战 58 : 诡异的直角三角形周长

[复制链接]
楼主
发表于 2015-3-30 08:23:50 | 显示全部楼层
本帖最后由 ukyo502 于 2015-3-30 08:30 编辑

初等数论中相关思路~~
d:\我的文档\ahailei.png
python 代码
import time
c1=time.time()
#======================================
def gcd(a, b):
  if a < b:
    a, b = b, a
  while b != 0:
    temp = a % b
    a = b
    b = temp
  return a
#======================================
D={};count_D=0;Big=15*10**5
for x in xrange(2,int((Big/2)**0.5)):
      for y in xrange(x-1,0,-2):
            if gcd(x,y)==1:
                  L=2*x*(x+y)
                  for L1 in xrange(L,Big,L):
                        if L1 in D:
                              D[L1]+=1
                        else:
                              D[L1]=1
#==========================================
for z in D:
      if D[z]==1:
            count_D+=1
print count_D
print time.time()-c1

ahailei.png (94.92 KB, 下载次数: 0)

ahailei.png
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表