Project Euler__problem 9
来源:互联网 发布:淘宝查号代收怎么做 编辑:程序博客网 时间:2024/06/05 12:04
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。
暴力解....
#include<iostream> void main(){int a,b,c;for (a = 1; a < 334; a++)for (c = 334; c < 1000; c++){b = 1000 - a - c;if (a*a + b*b == c*c){std::cout << "这个数组为:" << std::endl;std::cout << "a= " << a << std::endl;std::cout << "b= " << b << std::endl;std::cout << "c= " << 1000 - a - b << std::endl;std::cout << "abc=" << a*b*(1000 - a - b) << std::endl;break;}}system("pause");}
最后的答案:31875000
阅读全文
0 0
- Project Euler__problem 9
- Project Euler__problem 1
- Project Euler__problem 2
- Project Euler__problem 3
- Project Euler__problem 4
- Project Euler__problem 5
- Project Euler__problem 6
- Project Euler__problem 7
- Project Euler__problem 8
- Project Euler__problem 10
- Project Euler - Problem 9
- Problem 9-Project Euter
- Project Euler 9
- Project Euler 9
- Project Euler Problem 9
- project Euler problem 9
- project euler 9
- project
- 学生成绩(指针)
- 646. Maximum Length of Pair Chain
- 无限轮播添加权限、架包
- 14个你可能不知道的JavaScript调试技巧
- 2017年PHP程序员未来路在何方
- Project Euler__problem 9
- 欢迎使用CSDN-markdown编辑器
- 理论经典:TCP协议的3次握手与4次挥手过程详解
- 文件上传
- 如何做到低延迟OTT视频直播
- 什么是 web 框架?
- 终端、shell、bash的区别联系
- 你从来没了解过的CSS浮动
- 高性能网站设计之缓存更新的套路