霹雳搅屎棍 @ 2018-09-03 08:11:22
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a,b,c;
int l[10];
bool vis,flag;
bool p[10];
int main(int argc, char** argv) {
scanf("%d%d%d",&a,&b,&c);
/*if(a==123&&b==456&&c==789){
printf("%d %d %d\n",a,b,c);
return 0;
}答案特判*/
for(int i=111;i<=999;i++){
flag=0;
memset(p,0,sizeof(p));
int j=i/a*b;
int k=i/a*c;
if(j>999||j<111||k>999||k<111)
continue;
l[1]=i/100;
l[2]=i%100/10;
l[3]=i%10;
l[4]=j/100;
l[5]=j%100/10;
l[6]=j%10;
l[7]=k/100;
l[8]=k%100/10;
l[9]=k%10;
for(int s=1;s<=9;s++){
if(!l[s]){
flag=1;
break;
}
for(int w=1;w<=9;w++){
if(l[s]==w&&p[w]){
flag=1;
//cout<<w;
break;
}
if(l[s]==w&&!p[w])
p[w]=1;
}
}
if(flag)
continue;
printf("%d %d %d\n",i,j,k);
vis=1;
}
if(!vis)
cout<<"No!!!"<<endl;
return 0;
}
by WA鸭鸭 @ 2018-09-06 13:27:47
@霹雳搅屎棍 123:456:789