HzuWHF


私信TA

用户名:I7I08I9047

访问量:76429

签 名:

我RUN了

等  级
排  名 18
经  验 20459
参赛次数 13
文章发表 127
年  龄 3
在职情况 学生
学  校 贺州学院
专  业

  自我简介:

解题思路:

        就是这么暴力。

参考代码 ① :

#include<bits/stdc++.h>
using namespace std;

bool arr[10];

void Judge(int mul, int i2) {
	int i1 = mul / i2, pos = 0, index;
	if (mul > 9876) return;
	
	char mulc[5], i1c[5], i2c[5];
	sprintf(mulc, "%d", mul); sprintf(i1c, "%d", i1); sprintf(i2c, "%d", i2);

	while (mulc[pos]) {
		arr[mulc[pos++] - '0'] = true;
	} pos = 0;
	
	while (i1c[pos]) {
		index = i1c[pos++] - '0';
		if (arr[index]) return;
		arr[index] = true;
	} pos = 0; 
	
	while (i2c[pos]) {
		index = i2c[pos++] - '0';
		if (arr[index]) return;
		arr[index] = true;
	}
	
	for (int i = 1; i < 10; i++)
		if (!arr[i]) return;
	printf("%s = %s x %s\n", mulc, i2c, i1c);
}

int main() {
	for (int mul = 1; mul < 9283; mul++)
		for (int i = 1; i < 101; i++) {
			if (mul%i != 0) continue;
			Judge(mul, i); memset(arr, 0, 10);
		}
}


参考代码 ② : 

#include<iostream> /* > _ < */

int main() {
	char Ans[][20] = { "4396 = 28 x 157",
                       "5346 = 18 x 297",
                       "5346 = 27 x 198", 
                       "5796 = 12 x 483", 
                       "5796 = 42 x 138", 
                       "6952 = 4 x 1738",
                       "7254 = 39 x 186", 
                       "7632 = 48 x 159",
                       "7852 = 4 x 1963", "" };
                       
	int index = 0;
	while (Ans[index][0])
		puts(Ans[index++]);
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区