Office中国论坛/Access中国论坛

标题: 请朋友帮帮我:求7个数在500以内的正整数,满足以下两个要求 [打印本页]

作者: jj21    时间: 2006-9-2 21:44
标题: 请朋友帮帮我:求7个数在500以内的正整数,满足以下两个要求
工作中要做资料需要70组,编起来太难了,请朋友们帮帮我

求A、B、C、D、E、F、G

第一个条件:A+B+C+D+E+F+G=500±5

第二个条件:(5B+4C+3D+2E+F)/(500-A)=2.8~3.2


作者: pureshadow    时间: 2006-9-3 05:30
求五元一次方程组啊?条件太少诶.....

还是偶太笨了,米有看明白[em04]
作者: 情比金坚    时间: 2006-9-3 12:25
Dim a, b, c, d, e, f, g As Integer
For k = 1 To 70
For a = 1 To 505
For b = 1 To 505
For c = 1 To 505
For d = 1 To 505
For e = 1 To 505
For f = 1 To 505
For g = 1 To 505
If (a + b + c + d + e + f + g) > 494 And (a + b + c + d + e + f + g) < 506 Then
If 5 * b + 4 * c + 3 * d + 2 * e + f / (500 - a) >= 2.8 And 5 * b + 4 * c + 3 * d + 2 * e + f / (500 - a) <= 3.2 Then
Cells(k, 2) = a
Cells(k, 3) = b
Cells(k, 4) = c
Cells(k, 5) = d
Cells(k, 6) = e
Cells(k, 7) = f
Cells(k, 8) = g
End If
End If
Next
Next
Next
Next
Next
Next
Next
Next

原理上是这样吧???不知道要算多久??
作者: pureshadow    时间: 2006-9-3 17:48
[em02]这还叫不懂代码?比偶强多了去了哈!
作者: 老鬼    时间: 2006-9-5 06:13
试试规划求解功能




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3