include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
const int N = 10;
int s[N];//记录每一种组合方式
bool vis[N];//记录是否被用过
int ans; //记录答案
int n;
int cal(int l, int r)//[l,r]为s数组的左右区间
{
int res = 0;
for (int i = l; i <= r; i++)
res = res * 10 + s[i];
return res;
}
bool check(int a, int b, int c)//判断所选的数是否满足条件
{
return (b % c == 0) && (a + b / c == n);
}
void dfs(int u)
{
if (u == 9)
{
//拆分每一种组合方式 拆成 整数+分数的形式
for (int i = 0; i < 8; i)
{
for (int j = i + 1; j < 8; j)
{
int a = cal(0, i);
int b = cal(i + 1, j);
int c = cal(j + 1, 8);
if (check(a, b, c)) ans;
// {
// cout << endl;
// cout << a << ” ” << b << ” ” << c << endl;
// ans;
// cout << ans;
// }
}
}
return;
}
for (int i = 1; i < 10; i++)
{
if (!vis[i])
{
s[u] = i;
vis[i] = true;
dfs(u + 1);
s[u] = 0;
vis[i] = false; //恢复现场
}
}
}
int main()
{
scanf(“%d”, &n);
dfs(0);
printf(“%d”, ans);
return 0;
}