我是俩循环暴力

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

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. jsp页面_按回车键触发事件

    一般在列表页面中,都会带有查询按钮,当输入完查询条件后,如果需要通过鼠标点击"查询"按钮才发起查询,那么就感觉不够方便,那么我们就可以修改为按下回车键的时候发起查询. <sc ...

  2. OpenLayers使用点要素作为标记

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...

  3. HTML之meta标签缓存控制

    <meta http-equiv="pragram" content="no-cache"> 禁止浏览器从本地缓存中调阅页面. 网页不保存在缓存中, ...

  4. web标准中定义id与class有什么区别吗

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x ...

  5. 数据库----ORACLE和MYSQL数据库简介

    一.什么是数据库? 数据库(Database---DB)按照组织.储存和管理数据的仓库.(理解以下三个概念)   数据(Data)用来描述事物的记录都可称数据,如文字音乐图像.   数据库系统(Dat ...

  6. linux系统 (实验一)实验楼的课程笔记

    实验楼的课程笔记 tab 键是命令补全 输入 tail  find / 立刻卡住 这时候ctrl+c 可以终端当前指令 一些常用的指令 Ctrl+d 键盘输入结束或退出终端 Ctrl+s 暂停当前程序 ...

  7. linux类库之log4j-LogBack-slf4j-commons-logging

    log4j http://commons.apache.org/proper/commons-logging/ http://logging.apache.org/log4j/2.x/ The Com ...

  8. poj3422 最小费用流

    一遍的话秩序要dp就好,但是这里要删去点.此题可以转化为最小费用流.开始我想了半天纠结怎么处理到过一次后值变0,看了书之后发现拆点解决了这个问题. 对于点t,拆为t-->t',容量为1,费用为负 ...

  9. 2018-8-14-解决-VS-跳转定义和-Resharper-重复

    title author date CreateTime categories 解决 VS 跳转定义和 Resharper 重复 lindexi 2018-8-14 17:35:6 +0800 201 ...

  10. 2019-8-31-dotnet-控制台-Hangfire-后台定时任务

    title author date CreateTime categories dotnet 控制台 Hangfire 后台定时任务 lindexi 2019-08-31 16:55:58 +0800 ...