|
|
back to boardWhere is wrong? Posted by msi 22 Apr 2003 22:26 var x,nx,ny,y,i,n: longint; c: char; e,k,l: integer; s,s2,s3,s4: string; begin read(y, x); if (x=1) or (y=1) then begin n:=0; writeln(n);end else begin if x>=y then begin ny:=y-1; nx:=ny+1; end; if x<y then begin nx:=x; ny:=nx; end; if (nx<1000000000) and (ny<1000000000) then begin n:=nx+ny-1;writeln (n); end else begin str(nx,s); str(ny,s2); if length(s)>=length(s2) then x:=length(s) else x:=length(s2); for i:=1 to x do begin nx:=0; ny:=0; if length(s)-i>=0 then val(s[length(s)-i+1],nx,e); if length(s2)-i>=0 then val(s2[length(s2)-i+1],ny,e); nx:=nx+ny; if i=1 then begin nx:=nx-1; if nx=-1 then begin nx:=9; l:=1; end; if nx>9 then begin k:=1; nx:=nx-10; str(nx,s3) end else begin k:=0; str(nx,s3); end; end else begin nx:=nx+k-l; l:=0;if nx=-1 then begin l:=1; nx:=9; end; if nx>9 then begin k:=1; nx:=nx-10 end else k:=0; str(nx,s3); end; s4:=s3+s4; end;writeln(s4);end;end; end. Oh mom ! Just find a rule and make it a lot easier! (-) Posted by uuuuuuu 22 Apr 2003 23:26 |
|
|