Special Pythagorean triplet

problem 9:Special Pythagorean triplet

题意:若a+b+c=1000,且a2+b2=c2,求abc

代码如下:

 1 #ifndef PRO9_H_INCLUDED
 2 #define PRO9_H_INCLUDED
 3
 4 int solve(){
 5     for(int i=1;i<=1000;++i)
 6     for(int j=1;i+j<1000;++j)
 7         if(i*i+j*j==(1000-i-j)*(1000-i-j))
 8             return i*j*(1000-i-j);
 9 }
10
11 #endif // PRO9_H_INCLUDED
时间: 2024-10-01 20:01:13

Special Pythagorean triplet的相关文章

[Perl 6][Project Euler] Problem 9 - Special Pythagorean triplet

[Perl 6][Project Euler] Problem 9 - Special Pythagorean triplet Description A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagore

Project Euler: Problem 9 Special Pythagorean triplet

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. 首先联立式子,消除c,得到关于ab的等式5

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 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

PE 001~010

题意: 001(Multiples of 3 and 5):对小于1000的被3或5整除的数字求和. 002(Even Fibonacci numbers):斐波那契数列中小于等于4 000 000的偶数求和. 003(Largest prime factor):求600 851 475 143的最大质因数. 004(Largest palindrome product):求由两个三位数相乘得到的最大回文数. 005(Smallest multiple):求能被1~20中所有数整除的最小正整数.

Project-Euler problem 1-50

最近闲的做了下Project Euler 上的题目,前面50题都比较简单,简单总结下.代码一般是Python和C/C++的 用Python 做这些题目简直是酸爽啊 一下代码可能不一定是我的,因为不知道论坛里面的回复不是永久的,所以我的代码有的丢了,可能找个和我的意思相近的代码.题目翻译是从 欧拉计划 | Project Euler 中文翻译站上面Copy 的表告我. Problem 1  Multiples of 3 and 5 10以下的自然数中,属于3和5的倍数的有3,5,6和9,它们之和是

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

本题来自 Project Euler 第9题:https://projecteuler.net/problem=9 # Project Euler: Problem 9: Special Pythagorean triplet # A Pythagorean triplet is a set of three natural numbers, # a < b < c, for which, a**2 + b**2 = c**2 # For example, 3**2 + 4**2 = 9 +

欧拉计划(python) problem 9

Special Pythagorean triplet Problem 9 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

欧拉计划第9题题解

Special Pythagorean triplet A Pythagorean triplet is a set of three natural numbers, \(a < b < c\) , for which, \(a^2 + b^2 = c^2\) For example, \(3^2 + 4^2 = 9 + 16 = 25 = 5^2\) . There exists exactly one Pythagorean triplet for which \(a + b + c =

ProjectEuler 009题

题目: 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. 代码: 1 #include<iostream