Description
#include <stdio.h>
#include <string.h>
int vd[10];
bool check(int a, int b){
int x;
if (a < 10000 || b < 10000)
vd[0] = 1;
while (a){
x = a % 10;
vd[x] = 1;
a /= 10;
}
while (b){
x = b % 10;
vd[x] = 1;
b /= 10;
}
int sum = 0;
for (int i = 0; i < 10; i++)
sum += vd[i];
if (sum == 10)
return true;
return false;
}
int main()
{
int n, a, b;
bool flag;
bool t = false;
while (~scanf("%d", &n) && n != 0){
if (t)
printf("\n");
flag = false;
for (a = 1234; a <= 98765; a++){
memset(vd, 0, sizeof(vd));
b = a * n;
if (check(a, b) && b < 100000){
flag = true;
printf("%05d / %05d = %d\n", b, a, n);
}
}
if (!flag)
printf("There are no solutions for %d.\n", n);
t = true;
}
return 0;
}