lrqSB @ 2024-08-21 09:56:56
#include<bits/stdc++.h>
using namespace std;
int main() {
int a, b, c,f=0,d[9];
cin >> a >> b >> c;
for (int i = 123; i <= 333; i++) {
for (int k = 123; k <= 987; k++) {
for (int j = 123; j <= 987; j++) {
d[0]=i%10;
d[1]=i/10%10;
d[2]=i/100;
d[3]=k%10;
d[4]=k/10%10;
d[5]=k/100;
d[6]=j%10;
d[7]=j/10%10;
d[8]=j/100;
if(i*b/a==k&&k*c/b==j){
if(d[0]!=d[1]&&d[0]!=d[2]&&d[0]!=d[3]&&d[0]!=d[4]&&d[0]!=d[5]&&d[0]!=d[6]&&d[0]!=d[7]&&d[0]!=d[8]&&d[1]!=d[2]&&d[1]!=d[3]&&d[1]!=d[4]&&d[1]!=d[5]&&d[1]!=d[6]&&d[1]!=d[7]&&d[1]!=d[8]&&d[2]!=d[3]&&d[2]!=d[4]&&d[2]!=d[5]&&d[2]!=d[6]&&d[2]!=d[7]&&d[2]!=d[8]&&d[3]!=d[4]&&d[3]!=d[5]&&d[3]!=d[6]&&d[3]!=d[7]&&d[3]!=d[8]&&d[4]!=d[5]&&d[4]!=d[6]&&d[4]!=d[7]&&d[4]!=d[8]&&d[5]!=d[6]&&d[5]!=d[7]&&d[5]!=d[8]&&d[6]!=d[7]&&d[6]!=d[8]&&d[7]!=d[8]&&
d[0]!=0&&d[1]!=0&&d[2]!=0&&d[3]!=0&&d[4]!=0&&d[5]!=0&&d[6]!=0&&d[7]!=0&&d[8]!=0){
cout<<i<<" "<<k<<" "<<j<<endl;
f++;
}
}
}
}
}if(f==0){
cout<<"NO!!!";
}
}
by lrqSB @ 2024-08-21 09:58:55
我觉得判断部分或循环部分太麻烦了,应该怎么改才好?
by lrqSB @ 2024-08-21 10:01:48
刚把第一个for循环改了一下,是for(int i=123;i<=329;i++)
by lrqSB @ 2024-08-21 10:03:50
第二个改成了for(int m=123;k<=659;k++) ,还是不行
by Yezi_damn @ 2024-08-21 10:17:54
@lion0617 反正我是暴力枚举的,你可以试试
by Atrium @ 2024-09-09 01:42:55
“cout<<"NO!!!";”中的O改为小写o。要解决RE应该在输入a,b,c后判断a是否为0