首页| 论坛| 消息
主题:啊有大牛跟我讲讲遗传算法?
回帖:Program bahe;
Var a:array[0..999]of boolean;
w:array[1..999]of integer;
n,total,max,i,j:integer;
Procedure Init;
Var i:integer;
Begin
Readln(n);
For i:=1 to n do
Begin
Readln(w);
Inc(total,w);
End;
total:=total div 2;
End;
Begin
Init;
max:=0;
Fillchar(a,sizeof(a),false);
a[0]:=true;
For i:=1 to n do
For j:=max downto 0 do
If (a)and(j+wmax then max:=j+w;
End;
For i:=total downto 0 do
If a then
Begin
Writeln(2*(total-i));
Break;
End;
End.
‹上一楼:大哥,不行啊

--> 查看全部回帖(4)
«返回主帖