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 |
哪位大哥帮忙看看啊~~~救命啊~1014var num,target:array[1..6] of longint; i,j,k,tot:longint; ans:boolean; procedure check; var temp,p:longint; begin temp:=0; for p:=1 to 6 do temp:=temp+target[p]*p; if temp=tot div 2 then ans:=true; end; procedure search(level:longint); var min,max,t:longint; begin if level=7 then begin check; exit; end; if (level=1) or (level=5) then begin if num[level]<=5 then begin min:=0; max:=num[level]; end else begin max:=(5+num[level]) div 2; if odd(num[level]) then min:=(num[level]-5) div 2 else min:=(num[level]-4) div 2; end; end else begin if num[level]<=6 then begin min:=0; max:=num[level]; end else begin max:=(6+num[level]) div 2; if odd(num[level]) then min:=(num[level]-6) div 2 else min:=(num[level]-5) div 2; end; end; if num[level]=0 then search(level+1) else for t:=min to max do begin target[level]:=t; search(level+1); end; end; begin { assign(input,'1014.in'); reset(input); assign(output,'1014.out'); rewrite(output);} k:=0; while true do begin tot:=0; for i:=1 to 6 do begin read(num[i]); tot:=tot+i*num[i]; end; if tot=0 then break; inc(k); if odd(tot) then begin writeln('Collection #',k,':'); writeln('Can ','''','t be divided.'); writeln; end; ans:=false; fillchar(target,sizeof(target),0); search(1); writeln('Collection #',k,':'); if ans then writeln('Can be divided.') else writeln('Can ','''','t be divided.'); writeln; end; { close(input); close(output);} end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator