通过枚举fghij并乘n来算abcde 然后判断数字是否0-9都有且不重复
#include <iostream>
#include <cstdio>
using namespace std;
int check(int m,int n)
{
int a[10]={};
while(n)
{
a[n%10]++;
n/=10;
}
while(m)
{
a[m%10]++;
m/=10;
}
for(int i=1;i<10;i++)
{
if(a[i]!=1)
return 0;
}
return 1;
}
int main()
{
//freopen("d:\\h.txt","w",stdout);
int n,T=1;
while(cin>>n&&n)
{
if(T++!=1)
cout<<endl;
int flag=0;
for(int i=1234;i*n<=98765;i++)
{
if(check(i,i*n))
{
flag=1;
printf("%05d / %05d = %d\n",i*n,i,n);
}
}
if(flag==0)
cout<<"There are no solutions for "<<n<<"."<<endl;
}
return 0;
}