【Project Euler】【Problem 9】Special Pythagorean triplet
2013-03-27 18:50
453 查看
Special Pythagorean triplet
Problem 9
A Pythagorean triplet is a set of three natural numbers, ab
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.
|
翻译:
特别的毕达哥拉斯三元数组
问题 9
一个毕达哥拉斯三元数组是有三个自然数组成, ab
c,
满足 a2 + b2 = c2
例如, 32 + 42 = 9 + 16 = 25 = 52.
存在一个正确的毕达哥拉斯三元数组满足 a + b + c =
1000.
找到abc的乘积.
|
#include <stdio.h> int main(int argc, char *argv[]) { int a=1; int b=1; int c=1; int range = 1000; for (a=1; a < range; a++) { for (b=1; b < range - a; b++) { c = range-a-b; if (a*a+b*b==c*c) { printf("result is %d \n",a*b*c); return 0; } } } return 0; }
相关文章推荐
- Project Euler: Problem 9 Special Pythagorean triplet
- (Problem 9)Special Pythagorean triplet
- 9 Special Pythagorean triplet - Project Euler
- Project Euler Problem 9: Special Pythagorean triplet
- (Problem 9)Special Pythagorean triplet
- Problem 9:Special Pythagorean triplet
- (Problem 9)Special Pythagorean triplet
- Problem 9 Special Pythagorean triplet (毕达哥拉斯三元数组...)
- Problem 9:Special Pythagorean triplet
- Project Euler 9 Special Pythagorean triplet
- project euler 9 Special Pythagorean triplet
- PE 009 Special Pythagorean triplet
- projecteuler---->problem=9----Special Pythagorean triplet
- projecteuler---->problem=9----Special Pythagorean triplet
- Special Pythagorean triplet
- projectEuler008 SpecialPythagoreanTriplet
- 欧拉项目第九题 Special Pythagorean triplet
- 欧拉计划(9)Special Pythagorean triplet
- Project Euler:Problem 87 Prime power triples
- [Project Euler]加入欧拉 Problem 6