问题描述:
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?
解决问题:
public class Problem39 {
public static int find_way(int number){
int count = 0;
for(int c=500; c>0; c--){
for(int a = c-1; a>(number-c)/2&&a>0; a--){
int b = number - a - c;
if(b>0&&b*b+a*a==c*c){
// System.out.println("a:"+a+",b:"+b+",c:"+c);
count++;
}
}
}
return count;
}
public static void main(String[] args){
int max = 0;
int mark = 0;
for(int i=1000; i>0; i--){
int tmp = find_way(i);
if(tmp>max){
max =tmp;
mark = i;
}
}
System.out.println(max+":"+mark);
}
}
分享到:
相关推荐
0-1-knapsack-problem-master (39).zip
据说着名犹太历史学家 Josephus有过以下的故事:在罗马人占领乔塔帕特后,39 个犹太人与Josephus及他的朋友躲到一个洞中,39个犹太人决定宁愿死也不要被敌人到,于是决定了一个自杀方式,41个人排成一个圆圈,由第1...
计算机网络期末复习
约瑟夫问题的求解方案,经典
This paper focus on the conflicting belief structure problem and comes up with an evidence trap problem. A method of determining whether to select the Dempster';s rule of combination or not when ...
TcxButton with cxbkDropDownButton.*work with RECREATEWND message for skined control has scrollbar.*Fix a memory leak bug.*Fix paint bug ...TSkindata.Options.xoMDIChildBorder which do not skin MDIChild form'...
约瑟夫问题(Josephus Problem)据说著名犹太历史学家 Josephus有过以下的故事:在罗马人占领乔塔帕特后,39 个犹太人与Josephus及他的朋友躲到一个洞中,39个犹太人决定宁愿死也不要被敌人到,于是决定了一个自杀...
MATLAB下,用遗传算法解决旅行商问题(TSP)、多旅行商问题(MTSP)及其变体(共计39种情况)的代码,具体说明详见README
VclSkin v2.75官方试用版,标题有'VclSkin demo'字样,其他功能照用。News in 2.75Fix bugs in IP4000 combobox. Add install.exe and uninstall.exe. Add "embedscrollbar" in Skindata.skin3rd ...
2009-8-16 10:18:39 org.directwebremoting.util.CommonsLoggingOutput info 信息: DWR Version 2.0.5 starting. 2009-8-16 10:18:39 org.directwebremoting.util.CommonsLoggingOutput info 信息: - Servlet Engine...
错误: Problem Occurred Generating Artifacts(Time of error : November 8,2009 6:54:39 PM GMT+08:00) Reason: Could not get list of suggested identity strategies from database. Probably a JDBC driver ...
Chapter 2 Evolution of the Major Programming Languages 39 2.1 Zuse’s Plankalkül 40 2.2 Minimal Hardware Programming: Pseudocodes 43 2.3 The IBM 704 and Fortran 45 2.4 Functional Programming: ...
39 3.6.5 Reusable barrier solution . . . . . . . . . . . . . . . . . . 41 3.6.6 Preloaded turnstile . . . . . . . . . . . . . . . . . . . . . . 43 3.6.7 Barrier objects . . . . . . . . . . . . . . . ...
Das et al's to constant time. In this paper, we also improve the algorithm of S. Das et al's in a constant time but by using a different construction of adiabatic evolution, i
39-组合-sum.md 40-组合和-ii.md 第43章 第46章 47-置换-ii.md 第48章 第49章 5个最长回文子串.md 50-powx-n.md 6字形转换.md 7-反向整数.md 9回文数101-150(数量:30) 第101章 第102章 103二叉树之字形水平...
Chapter 39. Inference of Gene Regulatory Network Based on Radial Basis Function Neural Network Chapter 40. Establishment of Optimal Control Strategy of Building-Integrated Photovoltaic Blind Slat ...
The Shellcoder's Handbook 2nd Edition About the Authors vii Acknowledgments xi Introduction to the Second Edition xxiii Part I Introduction to Exploitation: Linux on x86 ...Conclusion 39
数学题和我女儿一起送回家的数学拼图难题基本上是将数字放入数组中,如下例所示: 对于: 3 3|1|2|1|3|... 最多 36 是很快的,39 在我的 MBP 上需要几分钟。 Solutions up to 36.Solving : 33|1|2|1|3|2|Solving : 44|1
联想商用机开天M6600 BIOS 20KT41AUS,官网上未提供。这是官方提供的,刷BIOS程序在里面,用纯DOS启动才能运行,不能加EMM386以上的内存管理程序等,否则不能运行。... update the bios to connet ths problem.