群里的网友抛出了这样一道题
我的算法:
@H_404_9@static @H_404_9@void Main(@H_404_9@string[] args)
{
/*
* a + b - 9 = 4
* + - -
* c - d * e =4
* / * -
* f + g - h=4
* || || ||
* 4 4 4
* */
@H_404_9@int flag = 50;
@H_404_9@for(@H_404_9@int a=0;a<14; a++) //a
{
@H_404_9@for (@H_404_9@int b = 0; b <14; b++) //b
{
//a+b-9=4 故 a+b=13
@H_404_9@if ((a + b) == 13)
{
//9-e-h=4 故 e+h=5,e<6,h<6
@H_404_9@for (@H_404_9@int e = 0; e < 6; e++) //e
{
@H_404_9@for (@H_404_9@int h = 0; h < 6; h++) //h
{
@H_404_9@if ((e + h) == 5)
{
@H_404_9@for (@H_404_9@int c = 0; c < flag; c++) //c
{
//b-d*g=4,b[0-13] 故d*g<10,d,g<10
@H_404_9@for (@H_404_9@int d = 0; d < 10; d++) //d d*g<=9
{
@H_404_9@for (@H_404_9@int g = 0; g < 10; g++) //g
{
//考虑到f为被除数,故f>0,考虑整除c%f==0
@H_404_9@for (@H_404_9@int f = 1; f < flag; f++) //f
{
@H_404_9@while ((c % f )== 0&&(c - d * e) == 4 && (f + g - h) == 4 && (a + c / f) == 4 && (b - d * g) == 4)
{
Console.WriteLine("----------------------------------");
Console.Write("a:{0} ",a.ToString());
Console.Write("b:{0} ",b.ToString());
Console.Write("c:{0} ",c.ToString());
Console.Write("d:{0} ",d.ToString());
Console.Write("e:{0} ",e.ToString());
Console.Write("f:{0} ",f.ToString());
Console.Write("g:{0} ",g.ToString());
Console.WriteLine("h:{0} ",h.ToString());
Console.WriteLine("----------------------------------");
Console.ReadLine();
}
}
}
}
}
}
}
}
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。