* Created by clearbug on 2017/3/15.
*/
public class VampireNumber {
public static void main(String[] args) {
for (int i = 1000; i < 10000; i++) {
int [] arr = getArr(i);
if (check(i, arr)) {
System.out.println(i);
}
}
}
public static int[] getArr(int n) {
int[] result = new int[4];
for (int i = 0; i < result.length; i++) {
result[i] = n / (int) Math.pow(10, result.length - 1 - i);
n = n % (int) Math.pow(10, result.length - 1 - i);
}
return result;
}
public static boolean check(int n, int[] arr) {
int length = arr.length;
for (int i = 0; i < length; i++) {
int a = arr[i];
for (int j = 0; j < length; j++) {
if (j == i) {
continue;
}
int b = arr[j];
for (int k = 0; k < length; k++) {
if (k == j || k == i) {
continue;
}
int c = arr[k];
for (int l = 0; l < length; l++) {
if (l == k || l == j || l == i) {
continue;
}
int d = arr[l];
if ((a * 10 + b) * (c * 10 + d) == n) {
System.out.println(a + ", " + b + ", " + c + ", " +d);
return true;
}
}
}
}
}
return false;
}
public static void printArray(int[] arr) {
for (int i = 0; i < arr.length; i++) {
if (i < arr.length - 1) {
System.out.print(arr[i] + ",");
} else {
System.out.println(arr[i]);
}
}
}
}