|
|
back to boardwhy I got WA? 3q Posted by noname 2 Aug 2002 22:24 program find_a_multiple; const maxn=1000; var n:integer; a:array[1..maxn] of integer; s:array[0..maxn] of integer; c:array[1..maxn,0..2] of integer; procedure init; var i:integer; begin readln(n); for i:=1 to n do readln(a[i]); end; procedure out(i,j:integer); var k:integer; begin for k:=i to j do write(a[k],' '); writeln; halt; end; procedure work; var i:integer; begin fillchar(s,sizeof(s),0); for i:=1 to n do s[i]:=(s[i-1]+a[i]) mod n ; fillchar(c,sizeof(c),0); for i:=1 to n do if s[i]=0 then out(1,i) else begin inc(c[s[i],0]); c[s[i], c[s[i],0]]:=i; if c[s[i],0]=2 then out(c[s[i],1]+1, c[s [i],2]); end; end; begin init; work; end. |
|
|