AC
2024-08-03 19:00:38
发布于:北京
6阅读
0回复
0点赞
```#include <bits/stdc++.h>
using namespace std;
int u;
int main(){
int num[10] = {};
int flag = 0;
for (int x = 1;x <= 9;x ++){
for (int y = 1;y <= 9;y ++){
for (int z = 1;z <= 9;z ++){
u = x * 100 + y * 10 + z;
int a = u * 2,b = u * 3;
if (a > 999 || b > 999) continue;
int a_1 = a % 10,a_2 = a / 10 % 10,a_3 = a / 100;
int b_1 = b % 10,b_2 = b / 10 % 10,b_3 = b / 100;
num[x] ++;
num[y] ++;
num[z] ++;
num[a_1] ++;
num[a_2] ++;
num[a_3] ++;
num[b_1] ++;
num[b_2] ++;
num[b_3] ++;
for (int i = 1;i <= 9;i ++){
if (num[i] > 1 || num[i] == 0){
flag = 1;
break;
}
}
if(!flag)cout << u << " " << a << " " << b << endl;
flag = 0;
for (int i = 1;i < 10;i ++) num[i]=0;
}
}
}
return 0;
}
这里空空如也
有帮助,赞一个