#include<iostream>
#include<set>
#include<cstring>
using namespace std;
int main()
{
int n,T=0;
while(cin>>n&&n)
{
if(T++)cout<<endl;
bool flag,solved=false;
int book[10];
for(int i=1234;i<=98765;i++)
{
memset(book,0,sizeof(book));
flag=true;
int a=i*n;
int b=i;
if(b<10000)book[0]=1;
while(a)
{
book[a%10]++;
a/=10;
}a=i*n;
while(b)
{
book[b%10]++;
b/=10;
}b=i;
for(int j=0;j<10;j++)if(book[j]!=1)
{
flag=false;break;
}
if(flag){printf("%d / %s%d = %d\n",a,b<10000?"0":"",b,n);solved=true;}
}
if(!solved)printf("There are no solutions for %d.\n",n);
}
return 0;
}
枚举除数,通过除数和商求出被除数,用book判断是否重复,注意输出回车
可以用搜索