Fu_Tao @ 2021-03-21 11:43:54
第三个wa了,没数据可看了
#include <iostream>
using namespace std;
long long a[10001],book[10001],x,y,z,flag=0;
void dfs(long long k){
if(k==10){
long double u=a[1]*100+a[2]*10+a[3];
long double v=a[4]*100+a[5]*10+a[6];
long double w=a[7]*100+a[8]*10+a[9];
if(u/x*x==u&&u/x*y==v&&u/x*z==w){
flag=1;
cout<<u<<" "<<v<<" "<<w<<endl;
return ;
}
return ;
}
for(int i=1;i<=10;i++){
if(book[i]==0){
a[k]=i;
book[i]=1;
dfs(k+1);
book[i]=0;
}
}
return ;
}
int main(){
cin>>x>>y>>z;
dfs(1);
if(flag==0){
cout<<"No!!!"<<endl;
}
return 0;
}
by metaphysis @ 2021-03-21 12:04:15
@醉梦伊人归
#include <iostream>
using namespace std;
int a[10001],book[10001],x,y,z,flag=0;
void dfs(int k){
if(k>=10){
long long u=a[1]*100+a[2]*10+a[3];
long long v=a[4]*100+a[5]*10+a[6];
long long w=a[7]*100+a[8]*10+a[9];
if(x * v == y * u && x * w == z * u){
flag=1;
cout<<u<<" "<<v<<" "<<w<<endl;
}
return;
}
for(int i=1;i<=9;i++){
if(book[i]==0){
a[k]=i;
book[i]=1;
dfs(k+1);
book[i]=0;
}
}
return ;
}
int main(){
cin>>x>>y>>z;
dfs(1);
if(flag==0){
cout<<"No!!!"<<endl;
}
return 0;
}
by Fu_Tao @ 2021-03-28 10:58:05
谢谢大佬