zoukankan      html  css  js  c++  java
  • Largest palindrome product

    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位数字的乘积的最大回文
     1 import java.util.ArrayList;
     2 import java.util.List;
     3 
     4 public class Main
     5 {
     6     public static void main(String[] args)   
     7     {
     8         List<Integer> list = new ArrayList<Integer>();
     9         int a=0;
    10         for(int i=99;i<1000;i++)
    11         {
    12             for(int j=99;j<1000;j++)
    13             {
    14                 list.add(j*i);
    15             }
    16         }
    17         List<Integer> lis = new ArrayList<Integer>();
    18         for(int i=0;i<list.size();i++)
    19         {
    20             if(list.get(i)>100000)
    21             {
    22                 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)
    23                 {
    24                     lis.add(list.get(i));
    25                 }
    26             }
    27         }
    28         int max=lis.get(0);
    29         for(int i=0;i<lis.size();i++)
    30         {
    31             if(max<lis.get(i))
    32             {
    33                 max=lis.get(i);
    34             }
    35         }
    36         System.out.println(max);
    37     }
    38 }

    结果:

    906609

  • 相关阅读:
    Django-ORM
    Django-路由系统
    Django-(Request对象和Response对象)
    Django-(CBV和FBV)
    批量设置模板中的时间格式
    Django模板语言-(母板、组件、静态文件相关、simple_tag、inclusion_tag)
    yii2csrf攻击
    centos6更改密码
    ide vscode安装
    xshell配色方案
  • 原文地址:https://www.cnblogs.com/niithub/p/5796252.html
Copyright © 2011-2022 走看看