社区讨论

40分求助

P1618三连击(升级版)参与者 3已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@m0ou863n
此快照首次捕获于
2024/09/05 13:19
2 年前
此快照最后确认于
2024/09/05 19:44
2 年前
查看原帖
CPP
#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;
 } 

回复

3 条回复,欢迎继续交流。

正在加载回复...