문제2628--Sequential Thinking

2628: Sequential Thinking

실행시간 제한: 1 Sec  메모리사용 제한: 128 MB
제출: 7  통과: 4
[제출] [채점기록] [묻고답하기]

문제 설명

Given an infinite sequence A with A[N] (N>=1) being the smallest multiple of 4 that begins with N, concatenate digits of A[N] to create an infinite string S. Chuck Norris can do this for you in his spare time.

What is the Kth digit in S?

Specifically, sequence begins as 12,20,32,4,52,60,..., resulting in S="12203245260...".

 

입력 설명

Number of cases, each case contains positive integer $K$ $(K \leq 10^{15})$.

Last case is followed by the line containing a single zero.

출력 설명

For each test case, print the $K$th digit of S on separate line.

입력 예시 Copy

1
7
15
0

출력 예시 Copy

1
4
9