| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大牛请进看为啥AC..var
f:array[0..101000]of boolean;
i,j,k,n,cash:longint;
v,p:array[1..20]of longint;
t:array[0..100100]of integer;
procedure renew;
begin
fillchar(f,sizeof(f),false);
f[0]:=true;
end;
procedure init;
var
i:longint;
begin
read(cash,n);
for i:=1 to n do read(p[i],v[i]);
end;
procedure dawn;
var
i,j,k:longint;
begin
for i:=1 to n do
begin
fillchar(t,sizeof(t),0);
for k:=0 to cash-v[i] do
if f[k] and (t[k]<p[i]) and(not f[k+v[i]]) then
begin
f[k+v[i]]:=true;
t[k+v[i]]:=t[k]+1;
end;
end;
end;
procedure print;
var
i:longint;
begin
for i:=cash downto 0 do if f[i] then
begin
writeln(i);
exit;
end;
end;
begin
repeat
renew;
init;
dawn;
print;
until seekeof;
end.
——————————————————————————————
上边for k:=0 to cash-v[i]如果改成for k:=0 to cash就wa了,为什么??!!
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator