about summary refs log tree commit diff
path: root/others/volume1/096.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-21 21:09:39 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-21 21:09:39 +0700
commit7d19f480637e9e880b98dabfbcf8e885b0a2d3b9 (patch)
treefa52914a2e58bc13570839fa297be05b7b7616bf /others/volume1/096.pas
parentf2d4bc6b7c302dee2d84a3acf84b83b5a98c45fa (diff)
downloadcp-7d19f480637e9e880b98dabfbcf8e885b0a2d3b9.tar.gz
Update others/volume1
Diffstat (limited to 'others/volume1/096.pas')
-rw-r--r--others/volume1/096.pas34
1 files changed, 34 insertions, 0 deletions
diff --git a/others/volume1/096.pas b/others/volume1/096.pas
new file mode 100644
index 0000000..4cb877c
--- /dev/null
+++ b/others/volume1/096.pas
@@ -0,0 +1,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.