|
|
back to boardI don't think my program is WRONG,who can tell me? THE RESULT IS WRONG ANSWER INSTEAD OF MEMORY LIMIT EXCEED SEE THIS: var a , b : array [1..1000002] of byte; i , n : longint; procedure jia; var p : integer; begin for p := 1 to n do begin b[p] := a[p] + b[p]; end; for p := 1 to n+2 do begin b[p+1] := b[p+1] + b[p] div 10; b[p] := b[p] mod 10; end; end; procedure out; var ws : longint; begin ws := n+5; if ws > 1000001 then ws := 1000001; while (b[ws]=0) and (ws<>1) do dec(ws); for i := ws downto 1 do write(b[i]); writeln; end; begin readln(n); for i := 1 to n do readln(a[n-i+1],b[n-i+1]); jia; out; end. Re: I don't think my program is WRONG,who can tell me? > THE RESULT IS WRONG ANSWER INSTEAD OF MEMORY LIMIT EXCEED > SEE THIS: > var > a , b : array [1..1000002] of byte; > i , n : longint; > procedure jia; > var > p : integer; > begin > for p := 1 to n do begin > b[p] := a[p] + b[p]; > end; > for p := 1 to n+2 do begin > b[p+1] := b[p+1] + b[p] div 10; > b[p] := b[p] mod 10; > end; > end; > procedure out; > var > ws : longint; > begin > ws := n+5; > if ws > 1000001 then ws := 1000001; > while (b[ws]=0) and (ws<>1) do dec(ws); > for i := ws downto 1 do > write(b[i]); > writeln; > end; > > begin > readln(n); > for i := 1 to n do > readln(a[n-i+1],b[n-i+1]); > jia; > out; > end. > > > I think: 1) you should submit an online solution. I really don't know why it doesn't get an ML. 2) this solution is wrong. Read the problem text: Output file should contain EXACTLY N DIGITS in a single line representing the sum of these two integers, and then run the following: 4 0 0 0 0 0 0 0 0 The answer must be 0000, but you output 0. |
|
|