1.
/*
* ACM Contest training
* Problem: 725 - Division
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=9&page=show_problem&problem=666
*
* @author Christoph Goettschkes
* @version 1.0, 10/24/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.248
*/

import java.io.*;
import java.util.*;

class Main
{

public static List<Integer> numbers = new ArrayList<Integer>();
public static Map<Integer, List<Integer[]>> division = new HashMap<Integer, List<Integer[]>>();

public static void main(String[] args) throws Exception
{
findNumbers();
prepare();

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

String line = reader.readLine();
int n = Integer.parseInt(line);

while (n != 0) {

List<Integer[]> solutions = division.get(n);

if (solutions.isEmpty())
System.out.println("There are no solutions for " + n + ".");
else {
for (Integer[] i : division.get(n)) {
System.out.println(((i[0] < 10000) ? "0" : "") + i[0] + " / " + ((i[1] < 10000) ? "0" : "") + i[1] + " = " + n);
}
}

line = reader.readLine();
n = Integer.parseInt(line);
if (n != 0)
System.out.println("");
}
}

public static void prepare()
{
for (int i = 2; i <= 79; i++) {
List<Integer[]> cur = new ArrayList<Integer[]>();
division.put(i, cur);
for (int j : numbers) {
if (i * j >= 100000)
break;
if (!isPair(i * j, j))
continue;
cur.add(new Integer[] {i * j, j});
}
}

for (int i = 2; i <= 79; i++) {
if (division.get(i).isEmpty())
continue;
Collections.sort(division.get(i), new Comp());
}
}


public static void findNumbers()
{
for (int i = 1000; i < 100000; i++)
if (test(i))
numbers.add(i);
}

public static boolean test(int n)
{
int[] testing = new int[10];
if (n < 1000)
return false;
if (n < 10000)
testing[0]++;

while (n != 0) {
int ne = n % 10;
testing[ne]++;
n /= 10;
}

for (int i = 0; i < 10; i++)
if (testing[i] > 1)
return false;
return true;
}

public static boolean isPair(int a, int b) {
boolean[] check = new boolean[10];

long num = (long)a * 100000 + b;
if (num < 1000000000)
check[0] = true;

while (num != 0) {
int c = (int)(num % 10);
if (check[c])
return false;
check[c] = true;
num /= 10;
}

return true;
}

}

class Comp implements Comparator<Integer[]>
{
public int compare(Integer[] a, Integer[] b) {
if (a[0] < b[0])
return -1;

if (a[0] == b[0]) {
if (a[1] < b[1])
return -1;
if (a[1] == b[1])
return 0;
return 1;
}

return 1;
}
}