#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 15;
int path[N];
bool st[N];
int n, res;
void dfs(int u)
{
if(u > n)
{
for (int i = 1; i <= n; i ++ )
{
int a = path[4] * 100 + path[5] * 10 + path[6];
int b = path[7] * 100 + path[8] * 10 + path[9];
if(path[1] * path[3] * b + path[2] * b + a * path[3] == 10 * path[3] * b)
{
res++;
return;
}
}
}
for (int i = 1; i <= n; i ++ )
{
if(st[i] == false)
{
st[i] = true;
path[u] = i;
dfs(u + 1);
st[i] = false;
}
}
}
int main()
{
cin >> n;
dfs(1);
cout << res;
return 0;
}
0 回复
0 转发
0 喜欢
1 阅读



