已知下例條件
b>0,c>0,d>0,e>0,f>0,g>0,h>0
b+c+d+e+f+g+h=71
8013<=15b+40c+60d+160e+200f+260g+310h<=8033
求b,c,d,e,f,g,h的解
無論用什麼方法,sql和delphi語句都可以,只要能夠求出正確的解且寫明過程就ok.
b>0,c>0,d>0,e>0,f>0,g>0,h>0
b+c+d+e+f+g+h=71
8013<=15b+40c+60d+160e+200f+260g+310h<=8033
求b,c,d,e,f,g,h的解
無論用什麼方法,sql和delphi語句都可以,只要能夠求出正確的解且寫明過程就ok.
b=15 c=40 d=2040 e=4960 f=400 g=260 h=310
b=1 c=1 d=35 e=29 f=2 g=2 h=1
b=1 c=1 d=36 e=24 f=7 g=1 h=1
b=1 c=1 d=36 e=27 f=2 g=3 h=1
b=1 c=1 d=36 e=27 f=3 g=1 h=2
b=1 c=1 d=37 e=22 f=7 g=2 h=1
b=1 c=1 d=37 e=25 f=2 g=4 h=1
b=1 c=1 d=37 e=25 f=3 g=2 h=2
b=1 c=1 d=37 e=26 f=2 g=1 h=3
b=1 c=1 d=38 e=17 f=12 g=1 h=1
b=1 c=1 d=38 e=20 f=7 g=3 h=1
b=1 c=1 d=38 e=20 f=8 g=1 h=2
b=1 c=1 d=38 e=23 f=2 g=5 h=1
b=1 c=1 d=38 e=23 f=3 g=3 h=2
b=1 c=1 d=38 e=24 f=2 g=2 h=3
b=1 c=1 d=39 e=15 f=12 g=2 h=1
b=1 c=1 d=39 e=18 f=7 g=4 h=1
b=1 c=1 d=39 e=18 f=8 g=2 h=2
b=1 c=1 d=39 e=19 f=7 g=1 h=3
b=1 c=1 d=39 e=21 f=2 g=6 h=1
請問可不可以指教指教
我要的是過程啊
解我是臏知道有,但只是推算法
procedure TForm1.Button4Click(Sender: TObject);
var
i, b, c, d, e, f, g, h: integer;
begin
i := 0;
for b:=1 to 71 do
for c:=1 to 71 do
for d:=1 to 71 do
for e:=1 to 51 do
for f:=1 to 41 do
for g:=1 to 31 do
for h:=1 to 26 do
begin
Application.ProcessMessages;
if (b+c+d+e+f+g+h=71) and (15*b+40*c+60*d+160*e+200*f+260*g+310*h<=8033) and (15*b+40*c+60*d+160*e+200*f+260*g+310*h>=8013) then
begin
Memo1.Lines.Add('b='+IntToStr(b)+#9+'c='+IntToStr(c)+#9+'d='+IntToStr(d)+#9+'e='+IntToStr(e)+#9+'f='+IntToStr(f)+#9+'g='+IntToStr(g)+#9+'h='+IntToStr(h));
Inc(i);
end;
end;
ShowMessage('共有'+IntToStr(i)+'组结果');
end;