about summary refs log tree commit diff
path: root/others/volume1/043.pas
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/043.pas
parent1cfc8e7ba45619f8a9837b4438c609948800dfff (diff)
downloadcp-b76eee8ea94df8048f2a7ae901856a480a43e8aa.tar.gz
Update others/volume1
Diffstat (limited to 'others/volume1/043.pas')
-rw-r--r--others/volume1/043.pas22
1 files changed, 22 insertions, 0 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.