Baichuzhi @ 2024-08-12 10:21:06
#include <bits/stdc++.h>
using namespace std;
int d[14];
int main()
{
bool flag = 0;
int a , b , c;
cin >> a >> b >> c;
for (int i = 192; i <= 329; i++)
{
int x = i;
int y = i * 2;
int z = i * 3;
int sum = 0;
while (x != 0)
{
sum++;
int xx = x % 10;
x = x / 10;
d[sum] = xx;
}
while (y != 0)
{
sum++;
int yy = y % 10;
y = y / 10;
d[sum] = yy;
}
while (z != 0)
{
sum++;
int zz = z % 10;
z = z / 10;
d[sum] = zz;
}
sort(d + 1 , d + sum + 1);
int cnt = 0;
for (int j = 1; j <= 9; j++)
{
if (d[j] == j)
{
cnt++;
}
}
if (cnt == 9)
{
cout << i * a << " " << i * b << " " << i * c << endl;
flag = 1;
}
}
if (flag == 0)
{
cout << "No!!!";
}
return 0;
}
by SunSkydp @ 2024-08-12 10:24:12
a,b,c是给定的 x,y,z你拿样例乘干嘛
by simple_child @ 2024-08-12 10:24:56
@Baichuzhi
#include <bits/stdc++.h>
using namespace std;
int main()
{
int A,B,C;
bool flag = true;
cin >> A >> B >> C;
/*if(A==123 && B==456 && C==789)
{
cout<<123<<' '<<456<<' '<<789<<endl;
return 0;
}*/
for(int i = 1/*100*/ ; i <=329 ; i++)
{
int n = i*A*1000000+i*B*1000+i*C;
set<int> jh;
jh.insert(0);
while(n)
{
jh.insert(n%10);
n/=10;
}
if (jh.size()==10 && i * A<1000 && i * B < 1000 && i * C < 1000)
{
cout<< i*A << " " << i*B <<" " << i*C <<endl;
flag = false;
}
}
if (flag) cout << "No!!!"<<endl;
return 0;
}
我方法
by realheizi @ 2024-08-12 10:26:16
@Baichuzhi
int x = i;
int y = i * 2;
int z = i * 3;
能解释一下这段代码吗?
by Baichuzhi @ 2024-08-12 10:36:33
@realheizi 已经改正,谢谢!
@simple_child 谢谢!
@SunSkydp 已改正,谢谢!