输入正整数 n , 按从大到小的顺序输出所有形如 abcde/fghij = n 的表达式,其中a ~ j为0 ~ 9的数字(不可重复)。2 <= n <=79.
样例输入:
62
样例输出:
79546/01283 = 62
94736/01528 = 62
方法:以62为例
private bool isRepeat(string val)
{
bool result = true;
foreach(char s in val)
{
if (new Regex(s.ToString()).Matches(val).Count > 1)
{
result = false;
break;
}
}
return result;
}
protected void Button1_Click(object sender, EventArgs e)
{
int max = 98765;
int min = max / 62;
for (int i = 1234; i < min; i++)
{
if ((isRepeat((i * 62).ToString().PadLeft(5, '0') + i.ToString().PadLeft(5, '0'))))
{
Response.Write((62 * i).ToString().PadLeft(5, '0') + "/" + i.ToString().PadLeft(5, '0'));
Response.Write("<br />");
}
}
}