about summary refs log tree commit diff
path: root/others/volume1
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-03-01 19:27:53 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-03-01 19:27:53 +0700
commitb76eee8ea94df8048f2a7ae901856a480a43e8aa (patch)
treeb47668b4394a8724264aa26764c14e45e5b2a8ec /others/volume1
parent1cfc8e7ba45619f8a9837b4438c609948800dfff (diff)
downloadcp-b76eee8ea94df8048f2a7ae901856a480a43e8aa.tar.gz
Update others/volume1
Diffstat (limited to 'others/volume1')
-rw-r--r--others/volume1/043.pas22
-rw-r--r--others/volume1/README.md2
-rw-r--r--others/volume1/clib.pas10
3 files changed, 28 insertions, 6 deletions
diff --git a/others/volume1/043.pas b/others/volume1/043.pas
new file mode 100644
index 0000000..a7af017
--- /dev/null
+++ b/others/volume1/043.pas
@@ -0,0 +1,22 @@
+uses math;
+
+var
+  n, i, m: uint64;
+
+begin
+  readln(n);
+  n := n - 1;
+  i := 0;
+  while i < 18 do
+    begin
+      m := 9 * 10 ** i * (i + 1);
+      if m < n then
+        n := n - m
+      else
+        break;
+      i := i + 1
+    end;
+  m := i - (n - 1) mod (i + 1);
+  n := 10 ** i + (n + i) div (i + 1) - 1;
+  writeln(n div 10 ** m mod 10)
+end.
diff --git a/others/volume1/README.md b/others/volume1/README.md
index 6f93607..f9f87ef 100644
--- a/others/volume1/README.md
+++ b/others/volume1/README.md
@@ -1,2 +1,2 @@
 Do giới hạn preview của Github khá hạn chế nên các để bài được giữ trong
-[file PDF](README.md).
+[tệp PDF](https://github.com/mcsinyx/hsg/raw/master/others/volume1/READMD.pdf).
diff --git a/others/volume1/clib.pas b/others/volume1/clib.pas
index ee74243..964aa17 100644
--- a/others/volume1/clib.pas
+++ b/others/volume1/clib.pas
@@ -148,14 +148,14 @@ interface
 implementation
 
   procedure qsort(var a : intar);
-    procedure sort(l, r: int64);
+    procedure sort(l, h: int64);
       var
         i, j, x, y: int64;
 
       begin
         i := l;
-        j := r;
-        x := a[(l + r) div 2];
+        j := h;
+        x := a[(l + h) div 2];
 
         repeat
           while a[i] < x do
@@ -175,8 +175,8 @@ implementation
 
         if l < j then
           sort(l, j);
-        if i < r then
-          sort(i, r)
+        if i < h then
+          sort(i, h)
       end;
 
     begin