about summary refs log tree commit diff
path: root/others/volume1/096.pas
blob: 4cb877c6d12558ddca051906626a0f8a24251e84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
uses math, strutils;

var
  a, b: ansistring;
  n: int16;
  remain: boolean = false;
  d: uint8;

begin
  readln(a);
  readln(b);
  n := max(length(a), length(b)) + 1;
  a := addchar('0', a, n);
  b := addchar('0', b, n);
  repeat
    if remain then
      d := ord(a[n]) + ord(b[n]) - 47
    else
      d := ord(a[n]) + ord(b[n]) - 48;
    if d > 57 then
      begin
        dec(d, 10);
        remain := true
      end
    else
      remain := false;
    a[n] := chr(d);
    dec(n)
  until n = 0;
  if ord(a[1]) = 48 then
    writeln(copy(a, 2, length(a) - 1))
  else
    writeln(a)
end.