#include int x = 0, number = 0, count = 0; void Swap(int &a, int &b) { int temp = a; a = b; b = temp; } int getNum(int list[], int f, int r) { int i = 0, num = 0; for (i = f; i <= r; i++) num = list[i] + num * 10; return num; } void Prim(int list[], int k, int m) { if (k == m - 1) { int a = 0, b = 0, c = 0, bLast = 0; for (int i = 0; i < x; i++) { a = getNum(list, 0, i); bLast = ((number - a) * list[8]) % 10; for (int j = i + (8 - i) / 2; j < 8; j++) { if (list[j] == bLast) { b = getNum(list, i + 1, j); c = getNum(list, j + 1, 8); if (b % c == 0 && a + b / c == number) { ++count; } break; } } } } else { for (int i = k; i < m; i++) { Swap(list[k], list[i]); Prim(list, k + 1, m); Swap(list[k], list[i]); } } } int main() { int temp = 0; int list[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; scanf("%d", &number); temp = number; while (temp != 0) { ++x; temp /= 10; } Prim(list, 0, 9); printf("%d", count); return 0; }