问题类型:输入输出,暴力求解
问题链接
03pie’s solution for [UVA-725]:
#include<bits/stdc++.h>//包含所有头文件
using namespace std;
typedef long long LL;
const double PI=acos(-1.0);
int main(){
freopen("F://inp.txt","r",stdin);
int n,first=1;
while(~scanf("%d",&n)&&n) {
int ok=0;
if(first) first=0;
else printf("\n");
for(int i=10000;i<100000;i++){
int j=i/n;
int x1=i%10,x2=(i/10)%10,x3=(i/100)%10,x4=(i/1000)%10,x5=i/10000;
int y1=j%10,y2=(j/10)%10,y3=(j/100)%10,y4=(j/1000)%10,y5=j/10000;
int z1=x4,z2=x5,z3=y4,z4=y5;
if(x1!=x2&&x1!=x3&&
x1!=y1&&x1!=y2&&x1!=y3&&
x1!=z1&&x1!=z2&&x1!=z3&&x1!=z4&&
x2!=x3&&
x2!=y1&&x2!=y2&&x2!=y3&&
x2!=z1&&x2!=z2&&x2!=z3&&x2!=z4&&
x3!=y1&&x3!=y2&&x3!=y3&&
x3!=z1&&x3!=z2&&x3!=z3&&x3!=z4&&
y1!=y2&&y1!=y3&&
y1!=z1&&y1!=z2&&y1!=z3&&y1!=z4&&
y2!=y3&&
y2!=z1&&y2!=z2&&y2!=z3&&y2!=z4&&
y3!=z1&&y3!=z2&&y3!=z3&&y3!=z4&&
z1!=z2&&z1!=z3&&z1!=z4&&
z2!=z3&&z2!=z4&&
z3!=z4&&n*j==i){
printf("%5d / %05d = %d\n",i,j,n); ok=1;
}
}
if(!ok) printf("There are no solutions for %d.\n",n);
}
return 0;
}