7.1.1 简单枚举
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
//freopen("out.txt","w",stdout);
int num1[50] = {0};
int num2[50] = {0};
int n,k,ix,sx,j,l,i;
bool flag;
cin>>n;
for( i = 01234; i < 99999; i++ )
{
ix = i;
k = 0;
while( ix % 10)
{
num1[k++] = ix % 10;
ix = ix / 10;
}
if(k==4) num1[4] = 0;
k++;
if(k!=5) continue;
flag = false;
for(j=0;j<5;j++)
{
for(l=j+1;l<5;l++)
{
if(num1[j]==num1[l])
{
flag = true;
break;
}
}
if(flag) break;
}
if(flag) continue;
sx = n * i;
k = 0;
while( sx % 10)
{
num2[k++] = sx % 10;
sx = sx / 10;
}
flag = false;
for(j=0;j<5;j++)
{
for(l=j+1;l<5;l++)
{
if(num2[j]==num2[l])
{
flag = true;
break;
}
}
if(flag) break;
}
if(flag) continue;
if(k==5)
{
flag = false;
for(j=0;j<5;j++)
{
for(l=0;l<5;l++)
{
if(num1[j]==num2[l])
{
flag = true;
break;
}
}
if(flag) break;
}
if(flag) continue;
printf("%05d/%05d=%d\n",n*i,i,n);
}
}
}