projecteuler Problem 9 Special Pythagorean triplet
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
译文:一个毕达哥拉斯三元数组是由三个自然数组成,a<b<c,形如
举个例子,32 + 42 = 9 + 16 = 25 = 52.
现在存在一个毕达哥拉斯三元数组,它满足 a + b + c = 1000.毕达哥拉斯三元数组的数值乘积。
第一次code:
public class Main { public static void main(String[] args) { System.out.println(run(1000)); } public static String run(int n) { String a=""; for(int i=1;i<n;i++) { for(int j=0;j<i;j++) { for(int s=0;s<j;s++) { if(s*s+j*j==i*i) { if(s+j+i == 1000) { a =String.valueOf(s*j*i); } } } } } return a; } }
时间效率:280毫秒。
projecteuler Problem 9 Special Pythagorean triplet的更多相关文章
- 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) ...
- (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 ...
- Special Pythagorean triplet
这个比较简单,慢慢进入状态. A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = ...
- projecteuler---->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 ...
- Project Euler Problem 9-Special Pythagorean triplet
我是俩循环暴力 看了看给的文档,英语并不好,有点懵,所以找了个中文的博客看了看:勾股数组学习小记.里面有两个学习链接和例题. import math def calc(): for i in rang ...
- projecteuler Problem 8 Largest product in a series
The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = ...
- Python练习题 037:Project Euler 009:毕达哥拉斯三元组之乘积
本题来自 Project Euler 第9题:https://projecteuler.net/problem=9 # Project Euler: Problem 9: Special Pythag ...
- Project Euler Problem9
Special Pythagorean triplet Problem 9 A Pythagorean triplet is a set of three natural numbers, a b ...
- PE 001~010
题意: 001(Multiples of 3 and 5):对小于1000的被3或5整除的数字求和. 002(Even Fibonacci numbers):斐波那契数列中小于等于4 000 000的 ...
随机推荐
- What is a watch descriptor
http://stackoverflow.com/questions/24342156/what-are-watch-descriptors-really-linux-inotify-subsyste ...
- jQuery--checkbox全选
jQuery.attr 获取/设置对象的属性值,如: $("input[name='chk_list']").attr("checked"); //读 ...
- maven 基本常识以及命令
Maven库: http://repo2.maven.org/maven2/ Maven依赖查询: http://mvnrepository.com/ Maven常用命令: 1. 创建Maven的普通 ...
- Eclipse上运行第一个Hadoop实例 - WordCount(单词统计程序)
需求 计算出文件中每个单词的频数.要求输出结果按照单词的字母顺序进行排序.每个单词和其频数占一行,单词和频数之间有间隔. 比如,输入两个文件,其一内容如下: hello world hello had ...
- vi 编辑器命令 (share)
转自:http://man.ddvip.com/soft/vieditor/vi.html 一.Unix编辑器概述 编辑器是使用计算机的重要工具之一,在各种操作系统中,编辑器都是必不可少的部件.Uni ...
- cocos2d-x 3.2 listview scorllview 等容器在小米华为等部分手机显示泛白解决
感觉记不住,代码贴上以免以后难找 在proj.android\src\org\cocos2dx\cpp\AppActivity.java 中的 public class AppActivity ext ...
- CheckBoxList 用法
<asp:CheckBoxList ID="cblqf" ForeColor="#4d6fc8" runat="server" Rep ...
- 《统计推断(Statistical Inference)》读书笔记——第4章 统计分布族
数据分析工作中最常和多维随机变量打交道,第四章介绍了多维随机变量的基本知识,其中核心概念是条件分布和条件概率.条件分布和条件概率可以抽象出条件期望的概念,在随机分析的研究中,理解随机积分和鞅理论和关键 ...
- IO-同步,异步,阻塞,非阻塞
IO-同步,异步,阻塞,非阻塞1.什么是IO数据在系统内核(kernel)和用户进程之间的传递,称为IO. 2.IO操作步骤以read为例,涉及两个系统对象,调用IO的process(or threa ...
- EDIUS设置Alpha转场的教程
有刚开始学习EDIUS视频编辑软件的同学吗?你们是否需要一本很好的EDIUS教程呢?你们可以到EDIUS中文网站里面找哦,小编会一直更新EDIUS教程的,能给你们带来帮助我是非常高兴的.今天我们来一起 ...