|
|
back to boardhelp!! I got memory limited!!Who can help me? Posted by qwt 8 Feb 2002 18:02 var x:array[1..10000] of integer; a:array[0..10000,0..10000] of 0..1; way:array[1..10000] of integer; q,i,j,k,n,o:integer; fin:boolean; begin fillchar(a,sizeof(A),0); a[0,0]:=1; readln(n); for i:=1 to n do begin readln(x[i]); if fin=false then begin if x[i] mod n=0 then begin writeln(1);writeln(x[i]);halt;end; for j:=n - (x[i] mod n) downto 0 do if (a[j,i-1]>0)and (fin=false) then begin a[j+x[i] mod n,i]:=1; a[j,i]:=1; if (j+x[i] mod n) mod n=0 then begin o:=i;fin:=true;end; end; end; end; j:=0;q:=n; while q<>0 do if a[q,o]=a[q,o-1] then dec(o) else begin inc(j); way[j]:=x[o]; q:=(q+n-x[o]) mod n; end; k:=0; for i:=1 to j do if way[i]=0 then inc(k); writeln(j-k); for i:=j downto 1 do if way[i]<>0 then writeln(way[i]); end. Array [0..10000,0..10000] is much greater than 1000K! (-) |
|
|