有点长,自己看
2024-12-14 11:01:48
发布于:广东
#include <iostream>
using namespace std;
int main(){
int n,xxx = 0;
cin >> n;
for (int a = 0;a<=9;a++){
for (int b = 0;b<=9;b++){
if(a == b){
continue;
}
for (int c = 0;c<=9;c++){
if(a == c||b == c){
continue;
}
for (int d = 0;d<=9;d++){
if(a == d||b == d||c== d){
continue;
}
for (int e = 1;e<=9;e++){
if(a == e||b == e||c== e||d == e){
continue;
}
int x = e+d10+c100+b1000+a10000;
int y = x * n,flag =1;
int num[10] = {0,1,2,3,4,5,6,7,8,9};
num[a] = -1;
num[b] = -1;
num[c] = -1;
num[d] = -1;
num[e] = -1;
for (int i = 0;i<5;i++){
if(num[y % 10] != -1){
num[y % 10] = -1;
}else{
flag = 0;
break;
}
y /= 10;
}
if(y == 0 && flag == 1){
xxx = 1;
cout << x*n<<" / ";
if(x<10000){
cout << 0<<x<<endl;
}else{
cout <<x<<endl;
}
}
}
}
}
}
}
if(xxx == 0){
cout <<"No answer.";
}
return 0;
}
这里空空如也
有帮助,赞一个