project euler 9
来源:互联网 发布:mac截图后文件在哪里 编辑:程序博客网 时间:2024/06/10 22:02
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。求这个三元组的乘积abc。
package projecteuler;import org.junit.Test;public class Prj9 {/** * 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. */@Testpublic void test() {int[] abc = getABC(1000);System.out.println("a=" + abc[0] + " ,b=" + abc[1] + " ,c=" + abc[2]);System.out.println("abc = " + abc[0] * abc[1] * abc[2]);}public int[] getABC(int num) {int[] ret = new int[3];for (int i = 1; i < num; i++) {for (int j = i + 1; j < num; j++) {for (int k = j + 1; k < num; k++) {if ((i * i + j * j == k * k) && (i + j + k == 1000)) {ret[0] = i;ret[1] = j;ret[2] = k;return ret;}}}}return ret;}}
0 0
- Project Euler - Problem 9
- Project Euler 9
- Project Euler 9
- Project Euler Problem 9
- project Euler problem 9
- project euler 9
- Project Euler problem 9 勾股数
- 【Project Euler】9 第九题
- Project Euler
- project euler
- Project Euler
- 【Project Euler】【Problem 9】Special Pythagorean triplet
- Project Euler: Problem 9 Special Pythagorean triplet
- 9 Special Pythagorean triplet - Project Euler
- Project Euler Problem 9: Special Pythagorean triplet
- project euler 9 Special Pythagorean triplet
- Project Euler .net
- Project Euler 0
- APUE学习之----socket编程实现简单的C/S
- E-斐波那契数
- 文本分类(二):scrapy爬取网易新闻
- Python中的os模块
- 树莓派(Raspberry pi)下安装七牛云c/c++ SDK时遇到的问题及解决方案
- project euler 9
- 带你走进AJAX(1)
- C开发(弱指令生成器)
- Linux C编程一站式学习
- Xlint deprecation编译警告解决
- 今天懂了3件事情
- 动画的常用的枚举值,动画先慢再快再慢,动画越来越快,动画越来越慢,动画匀速,动画期间允许交互
- Socket学习2
- Caffe 跑自己的数据和训练