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 |
什么叫没有证明?自己到未名bbs看一下!In Reply To:Re:help!!! Posted by:palmtenor at 2005-04-22 21:23:21 > 来来来,贴一个不用那种奇怪的没有证明的结论的真正的DP标程~~`:) > const > n =6; > > var > rock :array[1..n] of longint; > opt :array[0..60000] of boolean; > print :boolean; > mid :longint; > r :integer; > > procedure init; > var > i :integer; > begin > mid:=0; > print:=true; > for i:=1 to n do > begin > read(rock[i]); > mid:=mid+rock[i]*i; > if rock[i] mod 2=1 then print:=false; > end; > readln; > end; > > function min(a,b:longint):longint; > begin > if a<b then min:=a else min:=b; > end; > > procedure dp; > var > max :longint; > i :integer; > j,k :longint; > begin > fillchar(opt,sizeof(opt),false); > opt[0]:=true; > max:=0; > print:=true; > for i:=1 to n do > begin > if rock[i]>0 then > for j:=max downto 0 do > if opt[j] then > begin > if opt[mid] then begin writeln('Can be divided.');exit; end; > for k:=1 to rock[i] do > begin > if (j+k*i>mid) or opt[j+k*i] then break; > opt[j+k*i]:=true; > end; > end; > max:=max+i*rock[i]; > if max>mid then max:=mid; > end; > print:=false; > end; > > begin > init; > r:=0; > while mid<>0 do > begin > inc(r); > writeln('Collection #',r,':'); > if (mid mod 2=0) and not print then > begin > mid:=mid div 2; > dp; > if not print then writeln('Can''t be divided.') > end else > if print then writeln('Can be divided.') > else writeln('Can''t be divided.'); > writeln; > init; > end; > end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator