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

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. 15个不起眼但非常强大的 Vim 命令

    如果我的关于这个话题的最新帖子没有提醒到你的话,那我明确地说,我是一个 vim 的粉丝.所以在你们中的某些人向我扔石头之前,我先向你们展示一系列“鲜为人知的 Vim 命令”.我的意思是,一些你可能以前 ...

  2. fedora19安装jdk

    1.下载安装包 去oracle下载jdk-7u45-linux-i586.rpm 2. 更改权限 #chmod 777jdk-7u45-linux-i586.rpm 3. 安装 #rpm -ivh j ...

  3. 自然语言.例如:求n!。

    (1).定义3个变量i.n及mul,并为i和mul均赋初值为1. (2).从键盘中输入一个数赋给n. (3).将mul乘以i的结果赋给mul. (4)i的值加1,判断i的值是否大于n.如果大于n,则执 ...

  4. python_Opencv_处理鼠标事件

    流程: 首先,创建一个鼠标事件回调函数,当鼠标事件发生时就会被执行. 鼠标事件可以是鼠标上的任何动作,比如左键按下,左键松开,左键双击等. 我们可以通过鼠标事件获得与鼠标对应的图片上的坐标. 根据这些 ...

  5. TeamViewer或者向日葵等无法成功远程登录

    之前一直能正常远程的两台电脑,今天不知道什么原因,莫名其妙的就无法登录了. 更悲催的时,今天早上走的时候,忘把TeamViewer或者向日葵软件启动了. 还好,我登录向日葵官网,在管理中心设置里面开启 ...

  6. Reachability下载地址

    https://developer.apple.com/library/ios/samplecode/Reachability/Introduction/Intro.html

  7. linux下负载均衡(LVS安装与配置)【转】

    一.LVS的三种包转发方式      LVS提供了三种包转发方式:NAT(网络地址映射).IP Tunneling(IP隧道).Direct Routing(直接路由)     不同的转发模式决定了不 ...

  8. Spring AOP 实现原理与 CGLIB 应用--转

    AOP(Aspect Orient Programming),作为面向对象编程的一种补充,广泛应用于处理一些具有横切性质的系统级服务,如事务管理.安全检查.缓存.对象池管理等.AOP 实现的关键就在于 ...

  9. Java基础知识强化91:DateFormat类之DateFormat实现日期和字符串的相互转换

    1. DateFormat类概述: DateFormat 是日期/时间格式化子类的抽象类,它以与语言无关的方式格式化并解析日期或时间. 是抽象类,所以使用其子类SimpleDateFormat 2.  ...

  10. -bash: ulimit: open files: cannot modify limit: Operation not permitted

    普通用户登录系统报错,提示: -bash: ulimit: open files: cannot modify limit: Operation not permitted. 处理方法: #vi /e ...