#BS0000180. Dãy các nhóm số (Number Sequence)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Dãy các nhóm số (Number Sequence)
Number Sequence
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Define digit strings . The group is formed by writing the integers consecutively, with no separators.
For example, , , , and .
Concatenate the groups in order to obtain the infinite digit sequence . No characters are inserted between groups.
Given a positive integer , determine the digit at one-based position of this infinite sequence. Print exactly one digit, rather than the whole integer containing that digit.
Input
- The only line contains the integer , the one-based position of the requested digit.
Output
Print one digit character from 0 to 9: the digit at position .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
8
Output
2
Explanation
The first groups are , , , and . The first three groups contain digits. Position is the -th digit inside . The second digit of 1234 is 2.
Example 2
Input
3
Output
2
Explanation
contributes digit 1. The next group occupies positions and . Thus the third overall digit is the second digit of 12, namely 2.