• 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

  • 相关阅读:
    【BZOJ1053】[HAOI2007]反素数
    【BZOJ1052】[HAOI2007]覆盖问题
    【BZOJ1051】[HAOI2006]受欢迎的牛
    【BZOJ1050】[HAOI2006]旅行
    laravel 操作多数据库总结
    微服务浅述---架构演进
    分布式锁
    laravel自动生成model
    springboot集成quartz实现任务调度
    laravel 队列服务使用总结
  • 原文地址:https://www.cnblogs.com/niithub/p/5796252.html
Copyright © 2020-2023  润新知