CF BUDDY
← Problems·

1177B · Digits Sequence (Hard Edition)

1800 · binary search, divide and conquer, implementation

Problem: Let's write all the positive integer numbers one after another from 11 without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...

Your task is to print the kk-th digit of this sequence.

Input Format: The first and only line contains integer kk (1k10121 \le k \le 10^{12}) — the position to process (11-based index).

Output Format: Print the kk-th digit of the resulting infinite sequence.

Sample Cases

Case 1

Input

7

Output

7

Case 2

Input

21

Output

5

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback