除法 (Division,DVa 725 )

#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,j,ans=0,h=0,frist=0;
int a[11];
while(cin>>n&&n!=0)
{
h=0;
if(frist) cout<<endl;
for(int i=1234;i<50000;i++)
{ memset(a,0,sizeof(a));
ans=0;

if(i<10000)
a[i%10]=a[i/10%10]=a[i/100%10]=a[i/1000%10]=a[i/10000]=1;
else
a[i%10]=a[i/10%10]=a[i/100%10]=a[i/1000%10]=a[i/10000]=1;
j=i*n;
if(j<=98765)
{
a[j%10]=a[j/10%10]=a[j/100%10]=a[j/1000%10]=a[j/10000]=1;
}
for(int k=0;k<=9;k++)
{
ans+=a[k];
}
if(i<10000&&ans==10)
{
cout<<j<<" / 0"<<i<<" = "<<n<<endl;
h=1;
}
else if(ans==10)
{
cout<<j<<" / "<<i<<" = "<<n<<endl;
h=1;
}
frist=1;
}
if(h==0)
cout<<"There are no solutions for "<<n<<"."<<endl;

}
return 0;
}

猜你喜欢

转载自www.cnblogs.com/jiuren/p/10547391.html