Register @ 2018-07-20 10:41:24
以下是我的代码:
#include<iostream>
using namespace std;
int gw;
int d[10]={0};
int cf(int x){
while(x!=0){
gw=x%10;
x=(x-gw)/10;
d[gw]++;
}
}
int main(){
int a,b,c,A,B,C,total=0;
cin>>A>>B>>C;
if(A==0||B==0||C==0) return 0;
for (int i=1;i<=9;i++)
for (int j=1;j<=9;j++)
for (int k=1;k<=9;k++){
a=i*100+j*10+k;
if(a%A!=0) continue;
b=a/A*B;
c=a/A*C;
cf(a);
cf(b);
cf(c);
if(d[1]==1&&d[2]==1&&d[3]==1&&d[4]==1&&d[5]==1&&d[6]==1&&d[7]==1&&d[8]==1&&d[9]==1){
cout<<a<<" "<<b<<" "<<c<<endl;
total++;
}
for (int e=1;e<=9;e++){
d[e]=0;
}
}
if(total==0) cout<<"No!!!"<<endl;
return 0;
}
第四个测试点红色WA
by Register @ 2018-07-20 10:44:08
by Hinanawi_Feng @ 2018-08-03 22:24:40
@songhaoran 如果是你卡在最后一个点的话。 记住b 和 c一定要先乘再除。否则整除会不对,这里有一个坑
by Hinanawi_Feng @ 2018-08-03 22:26:47
(还有这么长时间了你应该早就A了)