Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

my code

Posted by 785045613 at 2011-09-29 20:38:16 on Problem 1014
var
  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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator