我是俩循环暴力

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

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. 威胁快报|Nexus Repository Manager 3新漏洞已被用于挖矿木马传播,建议用户尽快修复

    背景 近日,阿里云安全监测到watchbog挖矿木马使用新曝光的Nexus Repository Manager 3远程代码执行漏洞(CVE-2019-7238)进行攻击并挖矿的事件. 值得注意的是, ...

  2. jmeter 通过csv data set config 设置参数化后,执行结果显示为<EOF>

    通过csv data set config 设置参数化后,执行结果显示为<EOF>: 反复确认相应的参数的设置均没有问题,其中csv文件编码方式采用uft-8.在csv data set ...

  3. Hadoop 无法启动的问题

    最近乱搞把本来就快要挂了的hdfs又给弄坏了.问题如下, 应该是节点没有启动. [hadoop@namenode hadoop]$ hadoop dfsadmin -report Configured ...

  4. ICP算法(迭代最近点)

    参考博客:http://www.cnblogs.com/21207-iHome/p/6034462.html 最近在做点云匹配,需要用c++实现ICP算法,下面是简单理解,期待高手指正. ICP算法能 ...

  5. 微信小程序 —— wepy 使用 Vant Weapp

    一.下载 npm i @vant/weapp -S --production 下载完毕之后,就可以在 node_modules 文件夹里,看见下载的包了. 2.移动文件夹 把刚刚下载的包文件夹下的 l ...

  6. ajax请求 400 Bad Request, 然后就没进后台方法!

    原因可能是 ajax提交表单的data中实体的字段没有值(表单中无值填充的问题) 导致前台就已经报错了! 需要注意的字段类型 double  date  int .. 我就是因为这个double  , ...

  7. HTML之CSS标签

    1.CSS选择器 1).id选择器   2).class选择器 3).标签选择器   4).层级选择器(空格)    (1)id层级选择器       (2)class层级选择器 5).组合选择器(逗 ...

  8. Kubernetes1.4正式发布

    Kubernetes1.4正式发布. 昨天刚预测1.4即将正式发布,结果晚上Kubernetes1.4就正式发布了. 先看看Kubernetes发布历史: Kubernetes 1.0 - 2015年 ...

  9. QT_OPENGL-------- 4.可编程管线绘制三角形

    一.环境:qt下qmake编译首先在qt .pro文件中添加glew和glfw的链接 LIBS+= -L/usr/lib64 -lGLEW LIBS +=-L/usr/local/lib -lglfw ...

  10. ubuntu 使用glfw.h 出现函数无法调用

    最近在学习在Ubuntu下使用qt进行opengl开发,使用到了glfw这个库.我安装官网的编译和安装方法进行了配置安装,在usr/local/include的下产生了glfw.h文件. 于是我在我的 ...