BLX32M_10 @ 2021-08-02 14:36:05
#include <set>
#include <cstdio>
#include <vector>
using std::vector;
using std::set;
int a[9];
set<int> s;
vector<int> f, l, t;
int main()
{
double a, b, c, x, y, z;
int d, o, p;
scanf("%lf %lf %lf", &a, &b, &c);
for (int i = 1; i < 10; i++)
{
for (int j = 1; j < 10; j++)
{
if (j == i) continue;
for (int k = 1; k < 10; k++)
{
if (k == i || k == j) continue;
x = i * 100 + j * 10 + k;
y = x / a * b;
if (((int)y) != y || y > 987) continue;
z = y / b * c;
if (((int)z) != z || z > 987) continue;
d = x, o = y, p = z;
s.clear();
s.insert(i);
s.insert(j);
s.insert(k);
s.insert(o / 100);
s.insert(o / 10 % 10);
s.insert(o % 10);
s.insert(p / 100);
s.insert(p / 10 % 10);
s.insert(p % 10);
if (s.size() == 9)
{
f.push_back(d);
l.push_back(o);
t.push_back(p);
}
}
}
}
if (f.empty())
{
printf("No!!!");
return 0;
}
for (int i = 0; i < f.size(); i++)
{
printf("%d %d %d\n", f[i], l[i], t[i]);
}
}
by Fat_Fish @ 2021-08-02 15:56:50
您这个没有判 样例似乎过不了
by GGN_2015 @ 2021-08-18 09:34:26
输入 1 3 5
by BlackPanda @ 2021-09-12 08:44:32
可以用深度优先搜索DFS来做