ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1032. Find a Multiple

WA(1).why?And Accept?
Posted by pavel_perm 30 Jun 2004 00:28
WA(1)
var a:array[1..10000] of integer;
    c:array[0..9999] of integer;
    n,i,j:integer;
    s:integer;
    b:boolean;
begin
  fillchar(c,sizeof(c),255);
  s:=0;
  readln(n);
  b:=true;
  i:=0;
  while b do
  begin
    inc(i);
    read(a[i]);
    s:=(s+a[i])mod n;
    if s=0 then
    begin
      b:=false;
      writeln(i);
      for j:=1 to i do
      writeln(a[i]);
    end else
    if c[s]=-1 then
      c[s]:=i else
    begin
      b:=false;
      writeln(i-c[s]);
      for j:=c[s]+1 to i do
        writeln(a[j]);
    end;
  end;
end.
---------------------------------------
Accept:
var n,i,l,sum:integer;
    b:boolean;
    c,v:array[0..9999]of integer;
begin
  fillchar(v,sizeof(v),255);
  read(n);
  b:=true;
  i:=0;
  while b do
  begin
    read(c[i]);
    sum:=(c[i]+sum)mod n;
    if sum=0 then
    begin
      b:=false;
      writeln(i+1);
      for l:=0 to i do
    writeln(c[l]);
    end else
    if v[sum]=-1 then
      v[sum]:=i else
    begin
      b:=false;
      writeln(i-v[sum]);
      for l:=v[sum]+1 to i do
      writeln(c[l]);
    end;
    inc(i);
  end;
end.
----------------------------
I don't understand??????????