AC_710GD @ 2024-01-11 21:55:14
#include<bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, sum1, sum2, sum3, gcd1, gcd2, gcd, ans1, ans2, ans3, d1, d2, d3, e1, e2, e3, f1, f2, f3;
bool flag = 0;
scanf("%d%d%d", &a, &b, &c);
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) {
for (int k = 1; k <= 9; k++) {
for (int d = 1; d <= 9; d++) {
for (int e = 1; e <= 9; e++) {
for (int f = 1; f <= 9; f++) {
for (int g = 1; g <= 9; g++) {
for (int h = 1; h <= 9; h++) {
for (int l = 1; l <= 9; l++) {
sum1 = i * 100 + j * 10 + k;
sum2 = d * 100 + e * 10 + f;
sum3 = g * 100 + h * 10 + l;
gcd1 = __gcd(sum1, sum2);
gcd2 = __gcd(sum2, sum3);
gcd = __gcd(gcd1, gcd2);
ans1 = sum1 / gcd;
ans2 = sum2 / gcd;
ans3 = sum3 / gcd;
d1 = sum1 % 10;
d2 = sum1 / 10 % 10;
d3 = sum1 / 100;
e1 = sum2 % 10;
e2 = sum2 / 10 % 10;
e3 = sum2 / 100;
f1 = sum3 % 10;
f2 = sum3 / 10 % 10;
f3 = sum3 / 100;
if (ans1 == a && ans2 == b && ans3 == c && sum1 < sum2 && sum2 < sum3 && d1!=d2 && d1!=d3 && d1!=e1 && d1!=e2 && d1!=e3 && d1!=f1 && d1!=f2 && d1!=f3 && d2!=d3 && d2!=e1 && d2!=e2 && d2!=e3 && d2!=f1 && d2!=f2 && d2!=f3 && d3!=e1 && d3!=e2 && d3!=e3 && d3!=f1 && d3!=f2 && d3!=f3 && e1!=e2 && e1!=e3 && e1!=f1 && e1!=f2 && e1!=f3 && e2!=e3 && e2!=f1 && e2!=f2 && e2!=f3 && e3!=f1 && e3!=f2 && e3!=f3 && f1!=f2 && f1!=f3 && f2!=f3) {
printf("%d %d %d\n", sum1, sum2, sum3);
//printf("%d %d %d\n", ans1, ans2, ans3);
flag = 1;
}
}
}
}
}
}
}
}
}
}
if (!flag) {
printf("No!!!");
}
return 0;
}
by AC_710GD @ 2024-01-11 21:55:29
求助
by AC_710GD @ 2024-01-11 21:56:35
虽然答案对,但超时了
by _Supernova @ 2024-01-11 21:56:35
自己看一下题解。
by 半只蒟蒻 @ 2024-01-11 21:59:14
@AC_710GD 考虑枚举第一个数,然后按照比例算出另外两个数,然后判掉非法情况
by AC_710GD @ 2024-01-11 21:59:19
额,有你这么教的吗qwq
by RockyChen @ 2024-01-11 22:00:11
这段代码震惊我两年半
by 半只蒟蒻 @ 2024-01-11 22:00:34
@AC_710GD 咋了
by AC_710GD @ 2024-01-11 22:00:39
@半只蒟蒻 懂了,清楚
by AC_710GD @ 2024-01-11 22:01:56
蛋是我在题解里看到也有用9个for循环的,为什么他们能过
by AC_710GD @ 2024-01-11 22:03:06
我说@XX_Traveller_XX 有这么教的吗,没说你qwq