#P1895. Find the i-th Digit in S∞
Find the i-th Digit in S∞
Find the i-th Digit in S∞
Let \(\mathrm{tostring}(n)\) denote the decimal representation of a positive integer \(n\) (for example, \(\mathrm{tostring}(12345)=\mathtt{12345}\)). Using this function we define for each positive integer \(n\) the string
[ S_n = \mathrm{tostring}(1),\mathrm{tostring}(2),\cdots,\mathrm{tostring}(n), ]
and then define an infinite string by concatenating all these strings:
[ S_{\infty} = S_1,S_2,S_3,S_4,\cdots = \mathtt{1},\mathtt{12},\mathtt{123},\mathtt{1234},\cdots ]
For example, the first few characters of \(S_{\infty}\) are:
[ \mathtt{1,1,2,1,2,3,1,2,3,4,1,2,3,4,5,\cdots} ]
Your task is: given a positive integer \(i\), determine the \(i\)th character (1-indexed) in \(S_{\infty}\).
inputFormat
The input consists of a single positive integer \(i\) \(\,(1 \leq i \leq 10^{18})\,\) representing the position in \(S_{\infty}\).
outputFormat
Output a single character which is the \(i\)th character of \(S_{\infty}\).
sample
1
1