about summary refs log tree commit diff
path: root/others/volume1/043.pas
blob: a7af0179d2cb21c65cd0be185b55383f6b4462d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.