aleavf @ 2024-04-12 20:07:45
#include<bits/stdc++.h>
using namespace std;
int main(){
int a[10],b,d,x,y,z,s=0;
cin>>x>>y>>z;
for(int i=100;i<333;i++){
if(x==0||y==0||z==0){
break;
}
b=i*y/x;
d=i*z/x;
a[0]=i/100;
a[1]=i%100/10;
a[2]=i%10;
a[3]=b/100;
a[4]=b%100/10;
a[5]=b%10;
a[6]=d/100;
a[7]=d%100/10;
a[8]=d%10;
if(a[0]*a[1]*a[2]*a[3]*a[4]*a[5]*a[6]*a[7]*a[8]==362880&&a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]==45){
cout<<i<<' '<<b<<' '<<d<<endl;
s++;}
}
if(s==0){
cout<<"NO!!!";
}
}
by dhr10086 @ 2024-04-12 20:15:40
@aleavf
#include <bits/stdc++.h>
using namespace std;
int b[10];
void go(int x){
b[x % 10] = 1;
b[x / 10 % 10] = 1;
b[x / 100] = 1;
}
bool check(int x,int y,int z){
memset(b,0,sizeof(b));
if (y > 999 || z > 999) return 0;
go(x),go(y),go(z);
for (int i = 1;i <= 9;i++){
if (!b[i]) return 0;
}
return 1;
}
signed main(){
long long A,B,C,x,y,z,cnt = 0;
cin >> A >> B >> C;
for (int x = 123;x <= 987;x++){
if (A==0||x *B % A || x * C % A) continue;
y = x * B / A,z = x * C / A;
if (check(x,y,z)){
printf("%lld %lld %lld\n",x,y,z);
cnt++;
}
}
if (!cnt) puts("No!!!");
return 0;
}
by Liboy53_I_HATE_MATH @ 2024-04-12 20:39:34
我刚测试了一下,你这个代码在输入4 5 6输出错了