问题描述:
Take the number 192 and multiply it by each of 1, 2, and 3:
192 * 1 = 192
192 * 2 = 384
192 * 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)
The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).
What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n 1?
解决问题:
public class Problem38 {
public static boolean IsNumber(int number){
StringBuffer result = new StringBuffer();
int mul = 1;
while(result.length()<9){
String tmp = number*mul+"";
result.append(tmp);
mul ++;
}
if(result.length()!=9){
return false;
}else{
boolean[] elements = new boolean[10];
Arrays.fill(elements, true);
int r = Integer.parseInt(result.toString());
System.out.println("Result:"+r);
while(r!=0){
int cur = r%10;
if(cur==0||!elements[cur]){
return false;
}
elements[cur] = false;
r = r/10;
}
return true;
}
}
public static void main(String[] args){
for(int i=9999; i>0; i--){
if(IsNumber(i)){
System.out.println(i);
break;
}
}
System.out.println(IsNumber(9327));
}
}
分享到:
相关推荐
- **Applet示例**: 第38页提到了另一个Applet示例,说明书中可能包含了一些过时技术的介绍,因为Applet已经被大多数现代浏览器弃用。 - **算法编写**: 第42页提到为项目5编写算法,可能是在实际编程练习中如何设计...
离线安装包,亲测可用
日志错误error_log.log 提示: suEXEC mechanism enabled 日志nss_error_log.log 提示: ... Add "NSSEnforceValidCerts off" to nss.conf so the server can start until the problem can be resolved.
ACR38/100/122 PC/SC Driver Installer (MSI) Advanced Card Systems Ltd. Contents ---------------- 1. Release Notes 2. Installation 3. History 4. File Contents 5. Limitations 6. Support 1. ...
周二9月24日16:38:36 UTC 2019 我们想宣布CentOS Linux 8和 所有架构上的新CentOS Stream。 ---------- CentOS Linux 8 这是CentOS Linux 8的第一个版本,版本标记为 8.0-1905,来自Red Hat发布的资源,通过 git....
38计数与说.md 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...
1. **问题定义(D1:Define the Problem)**: - 选择明确的问题主题,确保目标具有可量化指标,如百分比、微米等。 - 描述问题的现状,包括问题发生的事物、地点、时间、发现者,以及影响程度。 2. **团队组建...
2. Professor Smith has been complete successful in working out the problem. → 改为 "Professor Smith has been completely successful in working out the problem." "complete"应改为副词"completely"以修饰...
CHAPTER 38 - Constrained Shortest Path Problem: Lagrangian Relaxation-Based Algorithmic Approaches CHAPTER 39 - Algorithms for Finding Disjoint Paths with QoS Constraints CHAPTER 40 - Set-Cover ...
通过PMC(Problem Management Center)工具可以读取完整的故障码信息,包括E/C代码、INFO、PHASE、POS以及发生的具体时间。如果没有PMC工具,也可以直接在CP28x板上读取E/C代码和INFO信息。 #### 故障码分析要点 在...
官方离线安装包,测试可用。请使用rpm -ivh [rpm完整包名] 进行安装
问题as_aritmeticos_bootcamp_fullstackdevDesafio proposto em BootCamp 布宜诺斯艾利斯2015年11月10日起在安达拉河畔布宜诺斯艾利斯举行的比赛中脱颖而出,并以10分钟的比赛成绩获得冠军,并在2014年以38封比赛...
Computer Networking: A Top-Down Approach, 6th Edition Solutions to Review Questions and Problems Version Date: May 2012 ...This document contains the solutions to review questions ...Problem 1 There...
7. 时间管理技巧:“Just for today I will try to live through this day only and not tackle my whole life problem at once.” 这句话可能作为每个部分的引言,强调了专注于当前任务而非一次性解决所有问题的...
##### 38. **LDAP_LOCAL_ERROR (82)** **描述:** 本地错误。 **处理方式:** 检查客户端配置及错误日志。 ##### 39. **LDAP_ENCODING_ERROR (83)** **描述:** 编码错误。 **处理方式:** 确保数据编码格式正确...
如"Kate always wears a smile on her face and looks happy"考察了动词短语和并列结构的使用,"This Maths problem is more difficult/harder than any other one"则涉及比较级的运用。同时,"Why didn’t you ...
它由福特汽车公司在1987年率先开发使用,称为《以小组为核心的解决问题的方法》-"Team Oriented Problem Solving" (TOPS)。8D方法擅长分析和解决问题,而六西格玛更适合应用于产品或过程的改善。8D方法常专用于解决...