From b76eee8ea94df8048f2a7ae901856a480a43e8aa Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Wed, 1 Mar 2017 19:27:53 +0700 Subject: Update others/volume1 --- others/volume1/043.pas | 22 ++++++++++++++++++++++ others/volume1/README.md | 2 +- others/volume1/clib.pas | 10 +++++----- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 others/volume1/043.pas (limited to 'others/volume1') 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 -- cgit 1.4.1