照着老师得来的,,,
#include<bits/stdc++.h>
using namespace std;
int check(int abcde, int fghij)
{
int used[10], d;
memset(used, 0, sizeof(used));
if(fghij < 10000)
used[0] = 1;
while(abcde) {
d = abcde % 10;
if(used[d])
return 0;
used[d] = 1;
abcde /= 10;
}
while(fghij) {
d = fghij % 10;
if(used[d])
return 0;
used[d] = 1;
fghij /= 10;
}
return 1;
}
int main(void)
{
int n, abcde, count, caseflag=0, end, i;
while(scanf("%d", &n) != EOF && n != 0) {
if(caseflag)
printf("\n");
caseflag = 1;
count = 0;
end = 98765 / n;
for(i=1234; i<=end; i++) {
abcde = i * n;
if(abcde >= 12345 && check(abcde, i)) {
printf("%05d / %05d = %d\n", abcde, i, n);
count++;
}
}
if(count == 0)
printf("There are no solutions for %d.\n", n);
}
return 0;
}