问题描述:
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));
}
}
分享到:
相关推荐
0-1-knapsack-problem-master (38).zip
打地鼠
离线安装包,亲测可用
日志错误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.
Three-Bar Truss 38 2.11 A General Mathematical Model for Optimum Design 41 2.11.1 Standard Design Optimization Model 42 2.11.2 Maximization Problem Treatment 43 2.11.3 Treatment of “Greater Than Type...
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. ...
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...
Chapter 38. Big Data Analytics in a Public General Hospital Chapter 39. Inference of Gene Regulatory Network Based on Radial Basis Function Neural Network Chapter 40. Establishment of Optimal Control ...
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 ...
问题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...
leetcode双人赛 Online-Judge 目录说明 utils:小工具包 Readme.py: A script that generates the ...problem ...problem ...38 NoneCpp 39 NoneCpp 40 NoneCpp 41 NoneCpp 42 NoneCpp 43 NoneCpp 44 NoneCp
leetcode 2 leetcode-解决方案 LeetCode 问题的解决方案来自 时间线 问题编号 地位 运行时间比 内存使用小于 提交日期 :check_mark: 91.47% 100.00% 2020-04-20 :check_mark: 90.01% ...93.38% 100.0
10.6 The Best Flow Problem—Not a Classical Graph Problem 165 10.6.1 Income Model for Customer Charges and Notations 166 10.6.2 Noncontinuous Price Function Paid to the Interworking Network for an ...
38.快速排序法(二) 88 39.快速排序法(三) 90 40.合并排序法 93 41.基数排序法 96 42.循序搜寻法(使用卫兵) 98 43.二分搜寻法(搜寻原则的代表) 100 44.插补搜寻法 103 45.费氏搜寻法 106 46.稀疏矩阵 110 47....
38. Downloads Counter V1.1.0 For Adobe Dreamweaver 39. DwZone Access DataBase Connection V1.2.0 For Adobe Dreamweaver 40. DwZone Advanced Form Controls V1.3.8 For Adobe Dreamweaver 41. DwZone Advanced...
38. Downloads Counter V1.1.0 For Adobe Dreamweaver 39. DwZone Access DataBase Connection V1.2.0 For Adobe Dreamweaver 40. DwZone Advanced Form Controls V1.3.8 For Adobe Dreamweaver 41. DwZone Advanced...
38. Downloads Counter V1.1.0 For Adobe Dreamweaver 39. DwZone Access DataBase Connection V1.2.0 For Adobe Dreamweaver 40. DwZone Advanced Form Controls V1.3.8 For Adobe Dreamweaver 41. DwZone Advanced...
38. Downloads Counter V1.1.0 For Adobe Dreamweaver 39. DwZone Access DataBase Connection V1.2.0 For Adobe Dreamweaver 40. DwZone Advanced Form Controls V1.3.8 For Adobe Dreamweaver 41. DwZone Advanced...