题目描述
blablabla
样例
#include<bits/stdc++.h>
using namespace std;
int ar[9] = {1,2,3,4,5,6,7,8,9};
int sum(int i, int j){
int ans = 0;
for(int k = i;k <= j;k++)
ans= ans*10 + ar[k];
return ans;
}
int main(){
int n, m,a ,an = 0;
cin>>a;
for(int i = 0;i < 362880;i++){ //9的全排类为362880个
for(int j = 0;j < 7;j++) //还是分三段
{
int re1 = sum(0,j);
for(int k = j+1;k < 8;k++){
int re2 = sum(j+1,k);
int re3 = sum(k+1,8);
if(a*re3 == re1*re3+re2) an++;
}
}
next_permutation(ar,ar+9); // 字典序+1后的全排列
}
cout<<an<<endl;
return 0;
}