about summary refs log tree commit diff
path: root/others/volume1/043.pas
diff options
context:
space:
mode:
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.