原题链接:https://www.luogu.com.cn/problem/P8599
全排列
//没有优化
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#define PII std::pair<ll,ll>
#define ll long long
ll n,m,k;
ll dx[] = {0,0,1,-1};
ll dy[] = {1,-1,0,0};
const ll N = 1e3;
ll op[N],dp[N][N];
ll ss(ll aa,ll bb){
ll res = 0;
// std::cout << "进去\n";
for(ll i = aa; i <= bb; i ++){
res = res * 10 + op[i];
}
// std::cout << res << "\n";
return res;
}
bool check(ll aa,ll bb,ll cc){
double kk = (aa * 1.0) + ((bb * 1.0) / (cc * 1.0));
if(kk == n) return true;
else return false;
}
void solve(){
std::cin >> n;
for(ll i = 1; i <= 9; i ++){
op[i] = i;
}
ll res = 0;
do{
// for(ll i = 1; i <= 9; i ++){
// std::cout << op[i] << " ";
// }
// std::cout << "\n";
for(ll i = 1; i <= 8; i ++){
ll jj = ss(1,i);
for(ll j = i + 1; j <= 8; j ++){
ll kk = ss(i + 1,j);
ll zz = ss(j + 1,9);
// std::cout << jj << " " << kk << " " << zz << "\n";
if(check(jj,kk,zz)) res ++;
}
}
}
while(std::next_permutation(op + 1,op + 1 + 9));
std::cout << res << "\n";
return ;
}
int main(){
ll t = 1;
while(t --)
solve();
return 0;
}