Sleep Disorder
InterviewTime limit1sMemory limit128 MB
Concatenate the natural numbers 1, 2, 3, ... into one digit string and return the digit at position N.
- Level
Medium4 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Kangmin has a sleep disorder and suffers quite a bit from not being able to fall asleep. Whenever sleep does not come he counts sheep in his head, but tonight he counted a million of them and was still awake.
Having had enough, Kangmin decided to count in a new way. Writing the natural numbers from 1 onward one after another produces this string of digits:
Kangmin read that string one digit at a time. He did fall asleep, and the next morning he woke up and happily shouted "I read all the way to digit !"
Which digit sits at position of the string?
Input
The first line contains .
Output
Print the single digit at position of the string. It is one of 0 through 9.