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 |
my codevar f:array[0..160000] of boolean; n:array[1..6] of longint; sum,time,i,j,k:longint; begin sum:=0;time:=1; for i:=1 to 6 do begin read(n[i]);sum:=sum+i*n[i]; end; while sum<>0 do begin writeln('Collection #',time,':'); if odd(sum) then writeln('Can''t be divided.') else begin sum:=sum shr 1;fillchar(f,sizeof(f),false);f[0]:=true; for i:=1 to 6 do if not f[sum] then for j:=sum downto 0 do if not f[sum] and f[j] then for k:=1 to n[i] do if (j+k*i<=sum) and not f[j+k*i] then f[j+k*i]:=true else break; if f[sum] then writeln('Can be divided.') else writeln('Can''t be divided.'); end; sum:=0;inc(time); for i:=1 to 6 do begin read(n[i]);sum:=sum+i*n[i]; end; if sum<>0 then writeln; end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator