You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
752 B
C++
25 lines
752 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int n, ans = 0;
|
|
scanf("%d", &n);
|
|
int num[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
|
|
do
|
|
{
|
|
for (int i = 1; i < 8; i++)
|
|
for (int j = i + 1; j < 9; j++)
|
|
{
|
|
int a = 0, b = 0, c = 0;
|
|
for (int k = 0; k < i; k++) a = a * 10 + num[k];
|
|
for (int k = i; k < j; k++) b = b * 10 + num[k];
|
|
for (int k = j; k < 9; k++) c = c * 10 + num[k];
|
|
if (b % c == 0 && n == a + b / c) ans++;
|
|
}
|
|
} while (next_permutation(num, num + 9));
|
|
printf("%d", ans);
|
|
return 0;
|
|
}
|