Arknight003 @ 2024-06-08 13:48:54
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int cnt[10];
void chai(int x)
{
while (x > 0)
{
cnt[x % 10]++;
x /= 10;
}
}
bool check(int x, int y, int z)
{
if (y > 999 || z > 999) return false;
memset(cnt, 0, sizeof(cnt));
chai(x);
chai(y);
chai(z);
for (int i = 1;i <= 9;i++)
{
if (cnt[i] != 1) return false;
}
return true;
}
int main()
{
int a, b, c;
cin >> a >> b >> c;
bool flag = true;
for (int x = 123; x <= 987; x++)
{
if (x == 0)
{
cout << "No!!!" << endl;
return 0;
}
if (x * b % a != 0 || x * c % a != 0) continue;
int y = x * b / a;
int z = x * c / a;
if (check(x, y, z))
{
cout << x << ' ' << y << ' ' << z << endl;
flag = false;
}
}
if (flag == true) cout << "No!!!" << endl;
return 0;
}
为什么有一个点RE了?
by Y_zhao111 @ 2024-06-08 13:55:48
@AKioi0101
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int cnt[100];
void chai(int x)
{
while (x > 0)
{
cnt[x % 10]++;
x /= 10;
}
}
bool check(int x, int y, int z)
{
if (y > 999 || z > 999) return false;
memset(cnt, 0, sizeof(cnt));
chai(x);
chai(y);
chai(z);
for (int i = 1;i <= 9;i++)
{
if (cnt[i] != 1) return false;
}
return true;
}
int main()
{
int a, b, c;
cin >> a >> b >> c;
if(a == 0 || b == 0 || c == 0)
{
cout << "No!!!" << endl;
return 0;
}
bool flag = true;
for (int x = 123; x <= 987; x++)
{
if (x == 0)
{
cout << "No!!!" << endl;
return 0;
}
if (x * b % a != 0 || x * c % a != 0) continue;
int y = x * b / a;
int z = x * c / a;
if (check(x, y, z))
{
cout << x << ' ' << y << ' ' << z << endl;
flag = false;
}
}
if (flag == true) cout << "No!!!" << endl;
return 0;
}
加个
by Arknight003 @ 2024-06-08 14:14:27
已经过了,谢谢大佬