这个比较简单,慢慢进入状态。

A Pythagorean triplet is a set of three natural numbers, a b c, for which,

a2 + b2 = c2

For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.

for a in xrange(1,1000):
    for b in xrange(1,1000):
        c = 1000 - (a + b)
        if (c * c) == (a * a + b * b):
            print a * b * c
            break

31875000
31875000
请按任意键继续. . .

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

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

  3. 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) ...

  4. projecteuler----&gt;problem=9----Special Pythagorean triplet

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

  5. Project Euler Problem 9-Special Pythagorean triplet

    我是俩循环暴力 看了看给的文档,英语并不好,有点懵,所以找了个中文的博客看了看:勾股数组学习小记.里面有两个学习链接和例题. import math def calc(): for i in rang ...

  6. PE 001~010

    题意: 001(Multiples of 3 and 5):对小于1000的被3或5整除的数字求和. 002(Even Fibonacci numbers):斐波那契数列中小于等于4 000 000的 ...

  7. Project Euler Problem9

    Special Pythagorean triplet Problem 9 A Pythagorean triplet is a set of three natural numbers, a  b  ...

  8. PE刷题记

    PE 中文翻译 最喜欢做这种很有意思的数学题了虽然数学很垃圾 但是这个网站的提交方式好鬼畜啊qwq 1.Multiples of 3 and 5 直接枚举 2.Even Fibonacci numbe ...

  9. Python练习题 037:Project Euler 009:毕达哥拉斯三元组之乘积

    本题来自 Project Euler 第9题:https://projecteuler.net/problem=9 # Project Euler: Problem 9: Special Pythag ...

随机推荐

  1. JVM调优之jstack找出最耗cpu的线程并定位代码

    jstack可以定位到线程堆栈,根据堆栈信息我们可以定位到具体代码,所以它在JVM性能调优中使用得非常多.下面我们来一个实例找出某个Java进程中最耗费CPU的Java线程并定位堆栈信息,用到的命令有 ...

  2. 一个非常有趣的算法程序(有趣只针对程序猿)就是Josephus问题

    大概花了一个晚上搭一个中午的时间,完善了一个关于Josephus的程序,这个Josephus游戏可是非常经典的算法,作为一个想从事软件的人最好能够理解一下,毕竟这个计算机教材上也讲过类似题目,具体的关 ...

  3. AIX Study之--AIX网卡配置管理(ent0、en0、et0)

    AIX Study之--AIX网卡配置管理(ent0.en0.et0) 1.查看AIX系统网卡信息: [root@aix211 /]#lsdev |grep et  en0 Available 1L- ...

  4. tomcat安全配置之禁用Directory Listing

    什么是Directory Listing?通俗点讲,就是在webapp的目录下如果没有放置index.html或者类似的文件,如果从IE或者其它浏览器文章这个路径时,会惊喜的发现这个目录下的文件列表被 ...

  5. Tomcat jdbc pool配置

    Tomcat jdbc pool是apache在tomcat7版本中启用的新连接池,用它来解决以往DBCP无法解决的一些问题. Tomcat jdbc pool的优点: (1)    tomcat j ...

  6. 跨平台传输中使用base64来保证非ascii码字符串的完整性

    首先,我们来看一个例子: byte[] b=new byte[]{2,9,43}; String ss=new String(b,"utf-8"); byte[] b1=ss.ge ...

  7. Linux驱动开发cdev驱动分层设计

    #ifndef MYDEV_H #define MYDEV_H #define DYNAMIC_MINOR 256 struct mydev{ const char *name; const stru ...

  8. [转] Transitions: Going from Shots to the Insulin Pump

    Part three of our article series on the common phases of type 2 diabetes management By Lance Porter ...

  9. nyoj 756 重建二叉树

    重建二叉树主要是给你一颗二叉树的前序遍历的结果和中序遍历的结果或者后序遍历的结果或者中序遍历的结果,让你求出其中的后序遍历的结果或者前序遍历的结果,这里知道其中的两个就能求出第三个,但是知道的两个必须 ...

  10. HTML5和CSS3实例教程[总结一]

    关于onclick的行为与内容分离 通过链接触发弹出窗口方式 (不推荐使用此方法!!!) <a href='#' onclcik = "window.open('holiday_pay ...