LCZZYX @ 2024-06-30 22:38:24
#include <iostream>
#include <cstring>
using namespace std;
int a[10];
int a1, a2, a3;
int c[4];
struct node {
int x, y, z;
} b[6] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}};
void f1(int i) {
a[i % 10]++;
a[i / 10 % 10]++;
a[i / 100 % 10]++;
}
bool f(int i, int j) {
memset(a, 0, sizeof(a));
f1(i);
f1(j);
int cnt = 0;
for (int i = 1; i < 10; i++) {
// cout << a[i] << " ";
if (a[i] != 1) {
c[cnt++] = i;
}
}
if (cnt == 3)
return 1;
return 0;
}
int get_k(int i, int j, int k) {
return c[i] * 100 + c[j] * 10 + c[k];
}
bool g(int i, int j, int k) {
if (i * a3 * a2 == j * a1 * a3 && j * a1 * a3 == k * a1 * a2)
return 1;
else
return 0;
}
int main() {
cin >> a1 >> a2 >> a3;
int fl = 1;
for (int i = 100; i <= 1000; i++) {
for (int j = i; j < 1000; j++) {
// for (int k = 100; k < 1000; k++) {
if (f(i, j) ) {
for (int i_1 = 0; i_1 < 6; i_1++) {
int k = get_k(b[i_1].x, b[i_1].y, b[i_1].z);
if (g(i, j, k)) {
fl = 0;
cout << i << " " << j << " " << k << endl;
}
}
}
// }
}
}
if (fl)
cout << "No!!!";
return 0;
}
输入 1 2 3,输入结果没问题吧,为啥不能过
by JackyLi @ 2024-07-25 14:56:20
@LCZZYX 得了几分?
by JackyLi @ 2024-07-25 15:01:38
@LCZZYX 可不可以加一个注释,这样我看得懂一些。谢谢!