using System;
publicclassHelloWorld
{
staticvoidMain(string[] args)
{
int i = int.Parse(Console.ReadLine());
string[] strings = newstring[5000];
int s = Print(i,strings);
Console.WriteLine(s);
for (int o=0;o<s;o++)
Console.WriteLine("{0}",strings[o]);
Console.ReadKey();
}
staticintPrint(int v, string[] strings)
{
int[] ints = newint[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int count = 0;
do
{
for (int i = 1; i <=7; i++)
{
for (int j = i + 1; j <= 8; j++)
{
int a = cvv(ints, 0, i);
int b = cvv(ints, i, j - i);
int c = cvv(ints, j, 9 - j);
if (b % c == 0 && v == a + b / c)
{
strings[count++]=$"{v} = {a} + {b}/{c}";
}
}
}
} while (aff(ints)) ;
return count;
}
staticintcvv(int[] ints, int start, int cou)
{
int num = 0;
for (int i = 0; i < cou; i++)
{
num = num * 10 + ints[start+i];
}
return num;
}
staticboolaff(int[] ints)
{
int i = ints.Length - 2;
while (i >= 0&& ints[i] >= ints[i+1]) i--;
if (i <0) returnfalse;
int j = ints.Length - 1;
while (j>i&&ints[i] <= ints[j]) j--;
Swap(ints, i, j);
Array.Reverse(ints,i+1,ints.Length-(i+1));
returntrue;
}
staticvoidSwap(int[] ints, int i, int j)
{
int temp = ints[i];
ints[i] = ints[j];
ints[j] = temp;
}
}