#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;
vector<int> path;
int used[10];
int res;
void dfs(int count){
if(count>9){
int x = path[4] * 100 + path[5] * 10 + path[6];
int y = path[7] * 100 + path[8] * 10 + path[9];
// 判断是否满足条件
if (path[1] * path[3] * y + path[2] * y + x * path[3] == 10* path[3] * y){
res++; // 满足条件的排列数量加一
return;
}
}
// 处理单层递归的逻辑
for(int i=1;i<=9;i++){
if(used[i]) continue;
path.push_back(i);
used[i]=1;
dfs(count+1);
used[i]=0;
path.pop_back();
}
}
int main(){
path.push_back(0);
dfs(1);
cout<<res;
return 0;
}
0 回复
0 转发
0 喜欢
2 阅读



