A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

译文:

 
利用相同的方法寻找回文数。两个2位数字的乘积的最大回文是9009=91×99。

得到两个3位数字的乘积的最大回文。

 import java.util.ArrayList;
 import java.util.List;

 public class Main
 {
     public static void main(String[] args)
     {
         List<Integer> list = new ArrayList<Integer>();
         int a=0;
         for(int i=99;i<1000;i++)
         {
             for(int j=99;j<1000;j++)
             {
                 list.add(j*i);
             }
         }
         List<Integer> lis = new ArrayList<Integer>();
         for(int i=0;i<list.size();i++)
         {
             if(list.get(i)>100000)
             {
                 if(list.get(i) % 10 ==list.get(i) / 100000 && (list.get(i) /10)% 10 ==(list.get(i) / 10000)%10 && (list.get(i) / 1000)%10 ==(list.get(i) / 100)%10)
                 {
                     lis.add(list.get(i));
                 }
             }
         }
         int max=lis.get(0);
         for(int i=0;i<lis.size();i++)
         {
             if(max<lis.get(i))
             {
                 max=lis.get(i);
             }
         }
         System.out.println(max);
     }
 }

结果:

906609

Largest palindrome product的更多相关文章

  1. 【欧拉计划4】Largest palindrome product

    欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/1371281760.html 原创:[欧 ...

  2. 欧拉计划之Largest palindrome product

    A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...

  3. (Problem 4)Largest palindrome product

    A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...

  4. [LeetCode] Largest Palindrome Product 最大回文串乘积

    Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...

  5. 【easy】479. Largest Palindrome Product

    Find the largest palindrome made from the product of two n-digit numbers Since the result could be v ...

  6. [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product

    Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...

  7. Problem 4: Largest palindrome product

    A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...

  8. LeetCode Largest Palindrome Product

    原题链接在这里:https://leetcode.com/problems/largest-palindrome-product/description/ 题目: Find the largest p ...

  9. 【LeetCode】479. Largest Palindrome Product 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...

随机推荐

  1. purple-accessData

    ylbtech-class:purple-accessData A, 返回顶部 1,送货时间 #region 送货时间 /// <summary> /// 送货时间 /// </su ...

  2. 数据库事务 及ACID

    数据库事务(Database Transaction) ,是指作为单个逻辑工作单元执行的一系列操作,要么完全地执行,要么完全地不执行. 事务处理可以确保除非事务性单元内的所有操作都成功完成,否则不会永 ...

  3. jQuery实现的美观的倒计时实例代码

    <!DOCTYPE html><html><head><meta charset=" utf-8"><meta name=&q ...

  4. 通过位运算生成ID

    public static void main(String[] args) { long serverId = 65535; System.out.println("ServerId:&q ...

  5. Java中Split函数的用法技巧

    在java.lang包中也有String.split()方法,与.net的类似,都是返回是一个字符型数组,但使用过程中还有一些小技巧.如执行:"2|33|4".split(&quo ...

  6. POJ 3744 【矩阵快速幂优化 概率DP】

    搞懂了什么是矩阵快速幂优化.... 这道题的重点不是DP. /* 题意: 小明要走某条路,按照个人兴致,向前走一步的概率是p,向前跳两步的概率是1-p,但是地上有地雷,给了地雷的x坐标,(一维),求小 ...

  7. MapHttpRoute

    http://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.Http/HttpRouteCollectionExten ...

  8. Kendo UI - Class 基类定义

    在 kendo 中,使用原型继承机制,Class 是 Kendo 中的基类,定义了函数 extend 用来派生其它类. function Class() {} Class.extend = funct ...

  9. windows Phone 浏览器窗口的尺寸

    移动设备的屏幕一般都比PC小很多,移动设备的浏览器会将一个较大的  “虚拟”  窗口映射到移动设备的屏幕上,然后按一定的比例(3:1或2:1)进行缩放.也就是说当我们加载一个普通网页的时候,移动浏览器 ...

  10. Appium输入中文的问题,简单的方法

    经常有人问,Appium怎么输入中文,下面提供一种相对简单的方式. 以前曾经提到过capabilities关键字,里面有这样2个属性, |`unicodeKeyboard`| 使用 Unicode 输 ...