6693.Digit Queries

Time Limit: 1s Memory Limit: 512MB

Consider an infinite string that consists of all positive integers in increasing order:

12345678910111213141516171819202122232425...

Your task is to process $q$ queries of the form: what is the digit at position $k$ in the string?

Input Format(From the terminal/stdin)

The first input line has an integer $q$ : the number of queries.

After this, there are $q$ lines that describe the queries. Each line has an integer $k$ : a $1$-indexed position in the string.

  • $1 \le q \le 1000$
  • $1 \le k \le 10^{18}$

Output Format(To the terminal/stdout)

For each query, print the corresponding digit.

Sample Input

Copy
3
7
19
12
 \n
 \n
  \n
  \n

Sample Output

Copy
7
4
1
 \n
 \n
 \n
Source: CSES, Introductory Problems, 2431

Submit

请先 登录

© 2025 FAQs