Project Euler:Problem 39 Integer right triangles
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For which value of p ≤ 1000, is the number of solutions maximised?
#include <iostream>
using namespace std; int main()
{
int ans = 0;
int maxp = 0;
for (int i = 12; i <= 1000; i++)
{
int maxc = 0;
for (int a = 1; a < i; a++)
{
for (int b = 1; b < a; b++)
{
int c = i - a - b;
if (c < 0)
break;
if (a*a + b*b == c*c)
maxc++;
}
}
if (maxc>ans)
{
ans = maxc;
maxp = i;
} }
cout << ans << " " << maxp << endl;
system("pause");
return 0;
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
Project Euler:Problem 39 Integer right triangles的更多相关文章
- Project Euler:Problem 86 Cuboid route
A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and a fly, F, sits in the o ...
- Project Euler:Problem 93 Arithmetic expressions
By using each of the digits from the set, {1, 2, 3, 4}, exactly once, and making use of the four ari ...
- Project Euler:Problem 55 Lychrel numbers
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindr ...
- (Problem 39)Integer right triangles
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exact ...
- Project Euler:Problem 63 Powerful digit counts
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is ...
- Project Euler:Problem 32 Pandigital products
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly o ...
- Project Euler:Problem 76 Counting summations
It is possible to write five as a sum in exactly six different ways: 4 + 1 3 + 2 3 + 1 + 1 2 + 2 + 1 ...
- Project Euler:Problem 87 Prime power triples
The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is ...
- Project Euler:Problem 89 Roman numerals
For a number written in Roman numerals to be considered valid there are basic rules which must be fo ...
随机推荐
- Android界面相关的类
Android界面相关的类 Window Activity的显示界面对象,并作为顶层View被加入到WindowManager中.Window提供了标准的UI显示策略:界面背景.标题区域.默认的事件处 ...
- centos php 安装memcached 扩展 支持sasl
1.安装sasl yum install cyrus-sasl-lib.x86_64 yum install cyrus-sasl-devel.x86_64 2.下载libmemcached wget ...
- 度量空间(metric space)
一个度量空间(metric space)由一个有序对(ordered pair)(M,d) 表示,其中 M 是一种集合,d 是定义在 M 上的一种度量,是如下的一种函数映射: d:M×M→R 且对于任 ...
- 9、基于Linux的v4l2视频架构应用编写
Linux系统中,视频设备被当作一个设备文件来看待,设备文件存放在 /dev目录下,完整路径的设备文件名为: /dev/video0 . 视频采集基本步骤流程如下: 打开视频设备,设置视频设备属性及采 ...
- 【38.02%】【codeforces 625B】War of the Corporations
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- iOS开发之Quarz2D:九:图形上下文矩阵操作
#import "VCView.h" @implementation VCView - (void)drawRect:(CGRect)rect { // Drawing code ...
- 【solr专题之二】配置文件:solr.xml solrConfig.xml schema.xml 分类: H4_SOLR/LUCENCE 2014-07-23 21:30 1959人阅读 评论(0) 收藏
1.关于默认搜索域 If you are using the Lucene query parser, queries that don't specify a field name will use ...
- 在RedHa上安装MRTG监控网卡流量
http://os.51cto.com/art/201103/252149.htm 2011-03-30 15:05 张微波 phpchina 字号:T | T 在RedHa上安装MRTG监控网卡流量 ...
- eclipse 远程debug tomcat web项目
1.首先须要在linux系统tomcat/bin文件夹下配置catalina.sh这个文件里添加: CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=d ...
- IE浏览器下css hack
\9 :所有IE浏览器都支持 _和- :仅IE6支持 * :IE6.IE7支持 \0 :IE8.IE9支持 \9\0 :IE8部分支持.IE9支持 \0\9 :IE8.IE9 ...