标签:
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.
译文:
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
标签:
原文地址:http://www.cnblogs.com/enginehome/p/5796252.html