40分求助
查看原帖
40分求助
1271475
jiaoxueyanghaoyu321楼主2024/9/5 13:19
#include <iostream>
#include <cstring>

using namespace std;

int a, b, c;
int num[100];
int find(int x) {
	if (a == 0) {
		return 0;
	}
	if (x * b % a != 0) {
		return 0;
	}
	int y = x * b / a;
	if (c * y % b != 0) {
		return 0;
	}
	int z = c * y / b;
	if (y < 100 or y > 999) {
		return 0;
	}
	if (z < 100 or z > 999) {
		return 0;
	}
	int x1 = x, y1 = y, z1 = z;
	memset(num, 0, sizeof(num));
	num[x % 10] ++;
	x /= 10;
	num[y % 10] ++;
	y /= 10;
	num[z % 10] ++;
	z /= 10;
	num[x % 10] ++;
	x /= 10;
	num[y % 10] ++;
	y /= 10;
	num[z % 10] ++;
	z /= 10;
	num[x % 10] ++;
	x /= 10;
	num[y % 10] ++;
	y /= 10;
	num[z % 10] ++;
	z /= 10;
	for (int i = 1; i <= 9; i ++) {
		if (num[i] != 1) {
			return 0;
		}
	}
	cout << x1 << " " << y1 << " " << z1 << endl;
}

int main()
{
	int f = 0;
	cin >> a >> b >> c;
	for (int i = 123; i <= 987; i ++) {
		if (find (i)) {
			f ++;
		}
	}
	if (f == 0) {
		cout << "No!!!\n";
	}
	return 0;
 } 
2024/9/5 13:19
加载中...