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

求助!!为何总是WA

Posted by sheikh at 2005-05-18 11:00:46 on Problem 1014
var
 a:array[1..6]of integer;
 ok:boolean;
 time,i:integer;
 f:boolean;
procedure out;
 begin
  writeln('Collection #',time,':');
  if ok then begin writeln('Can be divided.');writeln end
        else begin writeln('Can''t be divided.');writeln end
 end;
procedure main;
 var
  i,j,total,t:integer;
  b:array[1..20000]of integer;
  r:array[0..120000]of boolean;
 begin
  total:=0;
  for i:=1 to 6 do
   inc(total,i*a[i]);
  if total mod 2<>0 then begin ok:=false;exit end;
  fillchar(b,sizeof(b),0);
  fillchar(r,sizeof(r),false);
  r[0]:=true;
  t:=0;
  for i:=1 to 6 do
   while a[i]>0 do
     begin
      inc(t);
      b[t]:=i;
      dec(a[i])
     end;
  for i:=1 to t do
   for j:=total div 2 downto 1 do
    if j-b[i]>=0 then
     if (r[j])or(r[j-b[i]])
        then r[j]:=true;
  if r[total div 2]
     then ok:=true
     else ok:=false
 end;
begin
// assign(input,'input.txt');
// reset(input);
 time:=0;
 repeat
  f:=false;
  for i:=1 to 6 do
   begin
    read(a[i]);
    if a[i]<>0 then f:=true
   end;
  if not f then halt;
  inc(time);
  main;
  out;
 until false
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