#BS0000191. Dãy chữ số (phiên bản dễ) (Numerical Sequence (Easy Version))
Bài tập thuộc lộ trình
Mục lục đề ⌄
Dãy chữ số (phiên bản dễ) (Numerical Sequence (Easy Version))
Numerical Sequence (Easy Version)
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Consider an infinite string of decimal digits formed by concatenating blocks. Block is constructed by writing the positive integers consecutively, without separators.
The first blocks are 1, 12, 123, 1234, ...; their concatenation begins with 1121231234....
Digits in the infinite string are indexed starting from . For each independent query, find the single digit at position . Queries do not modify the string.
Input
- The first line contains , the number of queries.
- Each of the following lines contains an integer , the queried digit position.
Output
- Print lines. Line contains one digit from
0to9, at position .
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
5
1
3
20
38
56
Output
1
2
5
2
0
Explanation
The five queries ask for positions . The prefix of the infinite sequence is 11212312341234512345612345671234567812345678912345678910.
Counting digits from 1: position is 1; position is 2; position is 5; position is 2; and position is the last digit of 10, namely 0. These are precisely the five output lines.