yes
Time Limit: 2 seconds
Memory Limit: 1024 MB
Rating: 1800
Problem StatementDavid wrote down a sequence of all positive integers divisible by $K$, without any delimiters (i.e. as a single string) and in order. It will be an infinitely long string, but for this problem let’s assume David has discovered immortality and can somehow write all of this down. The string will start with $369121518212427\dots$ if $K = 3$. Compute the $N$-th digit/character in this string. $1 ≤ N ≤ 10^{12}, 1 ≤ K ≤ 1{,}000$
InputThe first line has two space-separated integers $N$ and $K$.
OutputOutput the answer.
Sample CasesSample Input 1: 3 3 Sample Output 1: 9 Sample Input 2: 1000000000000 943 Sample Output 2: 5Explanation
For the first test case, the third digit of the sequence $369121518212427\dots$ is $9$.
SourcesIanOJ Contest #3 (Div. 2) > Problem D
Submit | Back