xian_love @ 2024-07-13 16:30:51
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
bool flag = false;
for(int i1=1;i1<=9;i1++)
for(int i2=1;i2<=9&&i2!=i1;i2++)
for(int i3=1;i3<=9&&i3!=i2&&i3!=i1;i3++)
for(int i4=1;i4<=9&&i4!=i3&&i4!=i2&&i4!=i1;i4++)
for(int i5=1;i5<=9&&i5!=i4&&i5!=i3&&i5!=i2&&i5!=i1;i5++)
for(int i6=1;i6<=9&&i6!=i5&&i6!=i4&&i6!=i3&&i6!=i2&&i6!=i1;i6++)
for(int i7=1;i7<=9&&i7!=i6&&i7!=i5&&i7!=i4&&i7!=i3&&i7!=i2&&i7!=i1;i7++)
for(int i8=1;i8<=9&&i8!=i7&&i8!=i6&&i8!=i5&&i8!=i4&&i8!=i3&&i8!=i2&&i8!=i1;i8++)
for(int i9=1;i9<=9&&i9!=i8&&i9!=i7&&i9!=i6&&i9!=i5&&i9!=i4&&i9!=i3&&i9!=i2&&i9!=i1;i9++)
{
int ans1 = 100*i1+10*i2+i3;
int ans2 = 100*i4+10*i5+i6;
int ans3 = 100*i7+10*i8+i9;
if(ans1*b==a*ans2&&ans1*c==a*ans3){cout<<ans1<<" "<<ans2<<" "<<ans3<<endl;flag=true;}
}
if(!flag)cout<<"NO!!!";
return 0;
}
by gpxdzh @ 2024-07-13 16:34:00
@xian_love 牛哇牛哇
by gpxdzh @ 2024-07-13 16:34:38
看眼题解
by xian_love @ 2024-07-13 17:32:51
@gpxdzh 为何我的直接0pts
by xian_love @ 2024-07-13 17:33:12
我感觉逻辑没错啊@gpxdzh
by MCsky @ 2024-07-14 20:39:20
#include <iostream>
using namespace std;
bool chk(int n1,int n2,int n3){
int a[10]={0};
a[n1%10]++;
a[n1/10%10]++;
a[n1/100%10]++;
a[n2%10]++;
a[n2/10%10]++;
a[n2/100%10]++;
a[n3%10]++;
a[n3/10%10]++;
a[n3/100%10]++;
for(int i=1;i<=9;i++){
if(a[i]!=1){
return false;
}
}
return true;
}
int main(){
int a,b,c,i,j,k,cnt=0;
cin>>a>>b>>c;
if(a>0&&b>0&&c>0){
for(i=123;i<=987;i++){
if(i%a==0){
j=i/a*b;
k=i/a*c;
if(j<1000&&k<1000){
if(chk(i,j,k)==true){
cout<<i<<" "<<j<<" "<<k<<endl;
cnt++;
}
}
}
}
}
if(cnt==0)cout<<"No!!!"<<endl;
return 0;
}