public class Main {
public static void main(String[] args) {
for(int i = 10000 ; i <= 99999 ; i++) {
int sum = 0 ;
for(int j = 0 ; j < 5 ; j++) {
int shang = i / (int)Math.pow(10,j);
int yu = i % (int)Math.pow(10,j);
sum += shang * yu;
}
if(sum == i) {
System.out.print( i + " ");
}
}
}
}
完全可以暴力求完结果之后,存一个数组数组,“自欺欺人”变快了
public class Main {
public static void main(String[] args) {
int[] arr = {14610, 16420, 23610, 34420, 65500};
for(int i = 0 ; i < 5 ; i++) {
System.out.print(arr[i] + " ");
}
}
}