我是俩循环暴力

看了看给的文档,英语并不好,有点懵,所以找了个中文的博客看了看:勾股数组学习小记。里面有两个学习链接和例题。

import math

def calc():
for i in range(1,1000):
j = i+1
while j <= 1000:
c = i*i+j*j
c = int(math.sqrt(c))
if i+j+c > 1000:
break
if i < j < c and i+j+c == 1000 and i*i+j*j == c*c:
return i,j,c
j += 1
return 0,0,0 a,b,c = calc()
print a,b,c
print a*b*c

Project Euler Problem 9-Special Pythagorean triplet的更多相关文章

  1. projecteuler Problem 9 Special Pythagorean triplet

    A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 Fo ...

  2. Problem 9: Special Pythagorean triplet

    flag = 0 for a in range(1,1000): for b in range(a+1,1000): if a*a + b*b == (1000-a-b)**2: print(a,b) ...

  3. (Problem 9)Special Pythagorean triplet

    A Pythagorean triplet is a set of three natural numbers, a  b  c, for which, a2 + b2 = c2 For exampl ...

  4. Special Pythagorean triplet

    这个比较简单,慢慢进入状态. A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = ...

  5. Project Euler 106:Special subset sums: meta-testing 特殊的子集和:元检验

    Special subset sums: meta-testing Let S(A) represent the sum of elements in set A of size n. We shal ...

  6. Project Euler 103:Special subset sums: optimum 特殊的子集和:最优解

    Special subset sums: optimum Let S(A) represent the sum of elements in set A of size n. We shall cal ...

  7. Project Euler Problem 10

    Summation of primes Problem 10 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of ...

  8. Project Euler problem 62

    题目的大意很简单 做法的话. 我们就枚举1~10000的数的立方, 然后把这个立方中的有序重新排列,生成一个字符串s, 然后对于那些符合题目要求的肯定是生成同一个字符串的. 然后就可以用map来搞了 ...

  9. Project Euler problem 63

    这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for ...

随机推荐

  1. BZOJ2069: [POI2004]ZAW

    2069: [POI2004]ZAW Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 303  Solved: 138[Submit][Status][D ...

  2. HR招聘_(二)_招聘方法论(招聘原因及原则)

    1 招聘原因 离职 转岗 新增 工作量加大而无法负荷(若为短期工作量的加大可考虑外包或临时雇员) 业务发展需求(新产品线拓展,新事业部组建或组织架构变化等) 2 招聘原则 平等 面试官和候选人双方地位 ...

  3. python 中初始化二维数组的方法

    最好的方法是: 初始化4*3的二维数组 a = [[0 for col in xrange(3)] for row in xrange(4)] 而不可以用: a = [[0]*3]*4 [0]*3是生 ...

  4. CEF 框架使用集锦

    CEF 框架使用集锦: 参考:〓https://github.com/NetDimension/NanUI/wiki/%E5%BC%80%E5%A7%8B%E4%BD%BF%E7%94%A8NanUI ...

  5. java 2类与对象[学堂在线]

    java的面向对象方法和特征(略) 累的声明格式 语法:先定义一个引用变量名 穿件对象 new aclock=new CLock() 没有ststaic 就是实例变量 类变量static 类变量 方法 ...

  6. Leetcode914.X of a Kind in a Deck of Cards卡牌分组

    给定一副牌,每张牌上都写着一个整数. 此时,你需要选定一个数字 X,使我们可以将整副牌按下述规则分成 1 组或更多组: 每组都有 X 张牌. 组内所有的牌上都写着相同的整数. 仅当你可选的 X > ...

  7. PHP闭包实现函数的自调用实现递归

    根据pathinfo访问对应得controller,如ip:port/home/index/index则会访问home目录下的IndexController的index方法:如果不指定pathinfo ...

  8. java reference(转)

    http://blog.163.com/xubin_3@126/blog/static/112987702200962211145825/ 在Java中的引用类型,是指除了基本的变量类型之外的所有类型 ...

  9. 简单的Jquery焦点图切换效果

    利用Jquery,优雅的实现焦点图切换 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...

  10. 阿里小二的日常工作要被TA们“接管”了!

    昨天有人偷偷告诉我说 阿里巴巴其实是一家科技公司! 我想了整整一夜 究竟是谁走漏了风声 那么重点来了,阿里到底是如何在内部的办公.生活中,玩转“黑科技”的呢? AI取名:给你专属的“武侠”花名 花名是 ...