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 1048. Superlong Sums

Who know where is my mistake
Posted by TUIT_MAD 9 Mar 2008 16:25
var a,b:array[1..1000000] of  integer;
f:array[1..1000000]of integer;
n,v,e,k,u:integer;
begin
k:=0;
assign(input, 'input.txt'); reset(input);
assign(output, 'output.txt'); rewrite(output);
readln(n);
for v:=1 to n do begin
  read(a[v]);
  read(b[v]);
  readln
end;
for e:=n downto 1 do begin
 f[e]:=a[e]+b[e];
f[e]:=f[e]+k;
 if f[e]>9 then begin
 f[e]:=f[e]-10;
 k:=1;
 end
 else
 k:=0;
 if((e=1)and(f[e]>9)) then
 f[e]:=f[e]+10;
end;
for u:=1 to n do
write(f[u]);
end.
Re: Who know where is my mistake
Posted by ilya_romanenko 24 May 2011 23:51
var a,b:array[1..1000000] of integer;
f:array[1..1000000]of integer;
n,v,e,k,u:integer;
begin
k:=0;
readln(n);
for v:=1 to n do begin
  read(a[v]);
  readln(b[v]);
end;
for e:=n downto 1 do begin
 f[e]:=a[e]+b[e];
f[e]:=f[e]+k;
 if f[e]>9 then begin
 f[e]:=f[e]-10;
 k:=1;
 end
 else
 k:=0;
 if((e=1)and(f[e]>9)) then
 f[e]:=f[e]+10;
end;
for u:=1 to n do
write(f[u]);
end.

You shouldn't using input,output in your solution.
But i can't find your mistake too...

Edited by author 24.05.2011 23:51

Edited by author 24.05.2011 23:52
Re: Who know where is my mistake
Posted by Stepan 17 Nov 2013 15:14
if((e=1)and(f[e]>9)) then
 f[e]:=f[e]+10;

f[e]>9... Why do you plus 10? Sorry, I am Russian.