import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
String first_pathStr,second_pathStr;
ArrayList<Integer> arrayList1 = new ArrayList<>();
ArrayList<Integer> arrayList2 = new ArrayList<>();
int first_pathInt,second_pathInt;
char [] cDate; // массив для записи цифр по отдельности из ХХХХ числа
for (int i = 1000; i < 10000 ; i++) {
String s = Integer.toString(i); // переводим i-тую переменную в строку
cDate = s.toCharArray(); // разбивает строку посимвольно и записываем в массив.
for(int j = 0; j <4;j++){
for(int o = j+1; o <4;o++){
first_pathStr = ""+cDate[j] + cDate[o];
second_pathStr = ""+cDate[o] + cDate[j];
first_pathInt = Integer.parseInt(first_pathStr);
second_pathInt = Integer.parseInt(second_pathStr);
arrayList1.add(first_pathInt);
arrayList2.add(second_pathInt);
}}
for(int u = 0,t_i = 5; u < arrayList1.size();u++,t_i--){
if(arrayList1.get(u) * arrayList1.get(t_i) == i || arrayList1.get(u)*arrayList2.get(t_i) == i)
System.out.println(i);
if( arrayList2.get(u)*arrayList2.get(t_i) == i)
System.out.println(i);
}
arrayList1.clear();
arrayList2.clear();
}
}}
a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
for (d1 = 1; d1 <= 9; d1++) {
a[d1]++;
for (d2 = 0; d2 <= 9; d2++) {
a[d2]++;
for (d3 = d1; d3 <=9; d3++) {
a[d3]++;
for (d4 = (0 == d2 ? 1 : (d1 == d3 ? d2 : 0)); d4 <= 9; d4++) {
a[d4]++;
val1 = d1*10+d2;
val2 = d3*10+d4;
val = val1*val2;
b = [a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9]];
b[val%10]--;
b[Math.floor(val/10)%10]--;
b[Math.floor(val/100)%10]--;
b[Math.floor(val/1000)]--;
diff = 0;
for (i = 0; i < 9; i++)
diff |= b[i];
if (0 == diff)
console.log(val1, val2, val);
a[d4]--;
}
a[d3]--;
}
a[d2]--;
}
a[d1]--;
}
public class App {
private static final Integer START_NUM = 1000;
private static final Integer END_NUM = 9999;
private static final String ANSWER = "%d = %s * %s\n";
public static void main(String[] args) {
for (int num = START_NUM; num < END_NUM; num++) {
List<Integer> firstComb = new ArrayList<>();
List<Integer> secondComb = new ArrayList<>();
char[] number = String.valueOf(num).toCharArray();
for (int firstChar = 0; firstChar < 4; firstChar++) {
for (int secondChar = firstChar + 1; secondChar < 4; secondChar++) {
String firstHalf = "" + number[firstChar] + number[secondChar];
String secondHalf = "" + number[secondChar] + number[firstChar];
firstComb.add(Integer.valueOf(firstHalf));
secondComb.add(Integer.valueOf(secondHalf));
}
}
for (int i = 0, j = 5; i < firstComb.size(); i++, j--) {
if ((firstComb.get(i) * secondComb.get(j)) == num) {
System.out.printf(ANSWER, num, secondComb.get(j), firstComb.get(i));
break;
} else if ((firstComb.get(i) * firstComb.get(j)) == num) {
System.out.printf(ANSWER, num, firstComb.get(j), firstComb.get(i));
break;
} else if ((secondComb.get(i) * secondComb.get(j)) == num) {
System.out.printf(ANSWER, num, secondComb.get(j), secondComb.get(i));
break;
}
}
}
}
}