- 猫狗大战
- 2009-02-02 17:55:55 @
哪里的问题,根本没文件操作,却告诉我exitcode=103?
program ex;
const
maxn=200;
maxn2=maxn div 2;
maxrange=50;
var
c:array [0..maxn2,0..maxn2*maxrange] of boolean;
w:array [1..maxn] of byte;
n,n2:integer;
sum,k,min,ans:integer;
i,j:integer;
begin
sum:=0;
readln(n);
for i:=1 to n do
begin
readln(w[i]);
inc(sum,w[i]);
end;
n2:=(n+1) div 2;
fillchar(c,sizeof(c),0);
c[0,0]:=true;
for i:=1 to n do
for j:=n2-1 downto 0 do
for k:=maxrange*i downto 0 do
if c[j,k] then c[j+1,k+w[i]]:=true;
min:=maxint;
ans:=0;
for k:=0 to maxrange*n2 do
if c[n2,k] and (min>abs(sum-k*2)) then
begin
min:=abs(sum-k*2);
if k
1 条评论
-
No.Choser LV 8 @ 2016-08-20 14:50:46
神牛路过&
- 1